This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorParameterTable
Behavior element behavior adding parameter table support for actors.
Adds ParameterTable instance. This allows to store parameter with primitive or persistable type for game elements or global game state. Parameter tables are sometimes called “Black boards”. Various game scripts can set values in a table while other game scripts can read the values from the table without the individual systems knowing each other. For performance reasons the entries in the table are queried and can be stored locally to avoid looking them up all the time. In addition to primitive values parameters support objects implementing the Persistable interface. This allows parameter tables to be stored in save states easily. Parameter values are cleared by setting them to \em null. This avoids the need to remove parameters from the table.
The parameter table is a pure storage facility. No notifications about changes to parameter values is done in any way. If you need tracking state changes use TSTriggerTable or the EventTracker.
This behavior can be used only once on an element.
Element class properties have the prefix parameterTable.
.
This behavior has no events.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace parameterTree
with parameterTree(id)
.
Set one or more parameter tree parameters.
Parameter | Value | Description |
---|---|---|
name | string | Name of parameter to manipulate |
value | integer | Assign value to parameter |
value.increment | integer | Increment parameter by integer value. If parameter is not set 0 is used as current value |
value.decrement | integer | Decrement parameter by integer value. If parameter is not set 0 is used as current value |
This is an example of using this action:
<action name='parameterTree.set'> <parameter name='name'>counter</parameter> <parameter name='value.increment'>1</parameter> </action>
Check one or more parameter tree parameters. Action succeeds if all parameter value matches their respective parameter tree parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a parameter tree parameter matches (or not).
Parameter | Value | Description |
---|---|---|
name | string | Name of parameter to test |
value | integer | Value of parameter is integer value. If parameter is absent 0 is used as current value |
value.not | integer | Value of parameter is not integer value. If parameter is absent 0 is used as current value |
value.less | integer | Value of parameter is less than integer value. If parameter is absent 0 is used as current value |
value.greater | integer | Value of parameter is greater than integer value. If parameter is absent 0 is used as current value |
This is an example of using this action:
<sequence> <action name='parameterTree.check'> <parameter name='name'>counter</parameter> <parameter name='value.less'>3</parameter> </action> <!-- actions here run only if parameter tree parameter value is less than 3 --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace parameterTree
with parameterTree(id)
.
Check one or more parameter tree parameters. Conditions returns true if all parameter value match their respective parameter tree parameter. This condition is typically used to run an action or sequence of actions as long as parameter tree conditions are true.
Parameter | Value | Description |
---|---|---|
parameterTree.name | string | Name of parameter to test |
parameterTree.value | integer | Value of parameter is integer value. If parameter is absent 0 is used as current value |
parameterTree.value.not | integer | Value of parameter is not integer value. If parameter is absent 0 is used as current value |
parameterTree.value.less | integer | Value of parameter is less than integer value. If parameter is absent 0 is used as current value |
parameterTree.value.greater | integer | Value of parameter is greater than integer value. If parameter is absent 0 is used as current value |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='parameterTree.name'>counter</parameter> <parameter name='parameterTree.value.less'>3</parameter> </action>
This behavior requires no other behaviors.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which support parameter table.
class MyElement extends BehaviorElementClass public var ECBehaviorParameterTable parameterTrable func new() parameterTable = ECBehaviorParameterTable.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='ECBehaviorParameterTable'> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.name'>value</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorParameterTable' id='second'/> </elementClass>