This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorStashable
Behavior element behavior adding support for elements to be placed in ECBehaviorInventory.
This behavior can be used only once on an element.
Element class properties have the prefix stashable.
.
Set image to display in inventory screens.
stashable.image
*.webp
, *.png
, *.jpg
(all image modules)<string name='stashable.image'>inventory.webp</string>
Set video to display in inventory screens.
stashable.video
*.webm
(all video modules)<string name='stashable.video'>inventory.webm</string>
Set name to display in inventory screens.
stashable.name
<string name='stashable.name'>Cool Tool</string>
Set description to display in inventory screens.
stashable.description
<string name='stashable.description'>A cool tool every adventurer needs.</string>
Stashable has been added to inventory.
Stashable has been remove from inventory.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace stashable
with stashable(id)
.
Remove stashable from inventory if located in one.
Parameter | Value | Description |
---|---|---|
dispose | If present dispose of the stashable after removing it from the inventory, no matter if present in one or not |
This is an example of using this action:
<action name='stashable.remove'> <parameter name='dispose'>true</parameter> </action>
Check one or more stashable parameters. Action succeeds if all parameter value matches their respective stashable parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a stashable parameter matches (or not).
Parameter | Value | Description |
---|---|---|
stashed | true , false | Stashable is located in an inventory |
This is an example of using this action:
<sequence> <action name='stashable.check'> <parameter name='stashed'>true</parameter> </action> <!-- actions here run only if stashable is located in an inventory --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace stashable
with stashable(id)
.
Check one or more stashable parameters. Conditions returns true if all parameter value match their respective stashable parameter. This condition is typically used to run an action or sequence of actions as long as stashable conditions are true.
Parameter | Value | Description |
---|---|---|
stashable.stashed | true , false | Stashable is located in an inventory |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='stashable.stashed'>true</parameter> <condition>stashable.check</condition> </action>
This behavior requires no other behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which contains a resources.
class MyElement extends BehaviorElementClass public var ECBehaviorStashable stashable func new() stashable = ECBehaviorStashable.new(this) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorStashable'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>Cool Tool</string> </behavior> </elementClass>