User Tools

Site Tools


dragengine:modules:dragonscript:behavior_parametertree

ECBehaviorParameterTree

Behavior element behavior adding support to access a parameter tree.

The parameter tree can be loaded individually for each element instance or use the one loaded by the GWBehaviorParameterTree game world behavior. Using the game world behavior the data of multiple elements can be grouped in one parameter tree and accessed using a tree path. The data path should point to a data tree itself. This is not mandatory but recommended for using the convenience function to access the data path tree.

This behavior does not require the element class to be persistable.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix parameterTree..

path

Path to the parameter tree file to load.

  • Full name: parameterTree.path
  • Type: string
  • Default Value: empty string
  • Expected File Pattern: *.dept
  • Example (*.deeclass)
    <string name='parameterTree.path'>object_data.dept</string>

dataPath

Data path inside parameter tree. The data path should point to a data tree itself. This is not mandatory but recommended for using the convenience function to access the data path tree.

  • Full name: parameterTree.dataPath
  • Type: string
  • Default Value: empty string
  • Example (*.deeclass)
    <string name='parameterTree.dataPath'>config/objectData/identifier</string>

Events

This behavior has no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

This behavior does not require the element class to be persistable (setPersistable).

API Documentation

ECBehaviorParameterTree.

Since DragonScript Module Version 1.35

Use Cases

  • Store additional data for objects without needing to add behaviors with properties for each data.
  • Store configuration sets to select from.
  • Reuse configuration data across multiple objects without duplicating the data.

Element Class Example

This example defines an element which loads a parameter tree to store additional data. The data path is empty string referencing the entire tree.

class MyElement extends BehaviorElementClass
  public var ECBehaviorParameterTree parameterTree
  func new()
    parameterTree = ECBehaviorParameterTree.new(this)
    parameterTree.getPath().setValue("/content/dataTrees/myObject.dept")
  end
end

This example defines an element which uses the parameter tree loaded in the game world the element is added to. The data path references the sub tree to use.

class MyElement extends BehaviorElementClass
  public var ECBehaviorParameterTree parameterTree
  func new()
    parameterTree = ECBehaviorParameterTree.new(this)
    parameterTree.getDataPath().setValue("config/objectData/identifier")
  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='ECBehaviorParameterTree'>
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.dataPath'>config/objectData/identifier</string>
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_parametertree.txt · Last modified: by dragonlord