User Tools

Site Tools


dragengine:modules:dragonscript:behavior_parametertable

This is an old revision of the document!


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.

ParameterValueDescription
namestringName of parameter to manipulate
valueintegerAssign value to parameter
value.incrementintegerIncrement parameter by integer value. If parameter is not set 0 is used as current value
value.decrementintegerDecrement 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>

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).

ParameterValueDescription
namestringName of parameter to test
valueintegerValue of parameter is integer value. If parameter is absent 0 is used as current value
value.notintegerValue of parameter is not integer value. If parameter is absent 0 is used as current value
value.lessintegerValue of parameter is less than integer value. If parameter is absent 0 is used as current value
value.greaterintegerValue 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>

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.

ParameterValueDescription
parameterTree.namestringName of parameter to test
parameterTree.valueintegerValue of parameter is integer value. If parameter is absent 0 is used as current value
parameterTree.value.notintegerValue of parameter is not integer value. If parameter is absent 0 is used as current value
parameterTree.value.lessintegerValue of parameter is less than integer value. If parameter is absent 0 is used as current value
parameterTree.value.greaterintegerValue 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>

State Machine Actions

State Machine Conditions

State Machine Events

This behavior sends no state machine events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorParameterTable'>
    <!-- optional: use behavior tree with id instead of empty string -->
    <string name='behaviorTree'>second</string>
 
    <!-- optional: use state machine with id instead of empty string -->
    <string name='stateMachine'>second</string>
 
    <!-- 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>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_parametertable.1746223568.txt.gz · Last modified: 2025/05/02 22:06 by dragonlord