Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » 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.
This behavior can be used only once on an element.
Element class properties have the prefix parameterTree..
Path to the parameter tree file to load.
parameterTree.path*.dept<string name='parameterTree.path'>object_data.dept</string>
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.
parameterTree.dataPath<string name='parameterTree.dataPath'>config/objectData/identifier</string>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does not support optional behaviors.
This behavior does not require the element class to be persistable (setPersistable).
Since DragonScript Module Version 1.35
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
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>