{{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]] >> **ECBehaviorParameterTree** ====== 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 [[gwbehavior_parametertree|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) object_data.dept ===== 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) config/objectData/identifier ====== 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 ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorParameterTree.html,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: config/objectData/identifier ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]