{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorParameterTable**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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.
====== Instance Counts ======
This behavior can be used only once on an element.
====== Element Class Properties ======
Element class properties have the prefix ''parameterTable.'' .
====== Events ======
This behavior has no events.
====== Behavior Tree Actions ======
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''parameterTree'' with ''parameterTree(id)''.
===== parameterTree.set =====
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:
counter
1
===== parameterTree.check =====
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|
|wait| |If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled|
This is an example of using this action:
counter
3
====== Behavior Tree Conditions ======
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''parameterTree'' with ''parameterTree(id)''.
===== parameterTree.check =====
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:
counter
3
parameterTree.check
====== State Machine Actions ======
Same as [[#behavior_tree_actions|Behavior Tree Actions]].
====== State Machine Conditions ======
Same as [[#behavior_tree_conditions|Behavior Tree Conditions]].
====== State Machine Events ======
This behavior sends no state machine events.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use.
* [[behavior_statemachine|ECBehaviorStateMachine]]: Add actions and conditions for state machine to use and events to send to the state machine.
====== Persistency ======
This behavior does support element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorParameterTable.html,ECBehaviorParameterTable~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Store parameters of persistable data types for elements.
====== Element Class Example ======
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
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
second
second
value
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]