{{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]] >> **ECBehaviorEvaluate** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorEvaluate ====== Behavior element behavior evaluating trigger expression. Fires and resets a trigger target depending on the evaluation state of a trigger expression. Optionally pulses trigger target instead of just firing it. ====== Instance Counts ====== This behavior can be used multiple times on an element to add multiple triggers. Use the behavior identifier to tell them apart. ====== Element Class Properties ====== Element class properties have the prefix ''evaluate.'' or ''evaluate({id}).'' if id is not empty. ===== trigger ===== Trigger to evaluate. * Full name: ''evaluate.trigger'' or ''evaluate({id}).trigger'' * Type: string * Default Value: empty string * Example (*.deeclass) @switchOnVent & @powerEnabled ===== target ===== Fires target if trigger evaluates to true otherwise resets it. * Full name: ''evaluate.target'' or ''evaluate({id}).target'' * Type: string * Default Value: empty string * Example (*.deeclass) ventOn ===== pulse ===== Pulse target instead of toggle fired state. * Full name: ''evaluate.pulse'' or ''evaluate({id}).pulse'' * Type: boolean * Default Value: ''false'' * Example (*.deeclass) true ====== Events ====== ===== evaluatesTrue ===== Trigger expression changed to true. ===== evaluatesFalse ===== Trigger expression changed to false. ====== Behavior Tree Actions ====== This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''evaluate'' with ''evaluate(id)''. ===== evaluate.check ===== Check one or more evaluate trigger parameters. Action succeeds if all parameter value matches their respective evaluate trigger parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a evaluate trigger parameter matches (or not). ^Parameter^Value^Description^ |trigger|''true'', ''false''|Trigger expression evaluates to true or false| |target.fired|''true'', ''false''|Target is in fired or reset state| |target.everFired|''true'', ''false''|Target has been fired at least once or never| |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: false false ====== Behavior Tree Conditions ====== This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''evaluate'' with ''evaluate(id)''. ===== evaluate.check ===== Check one or more evaluate trigger parameters. Conditions returns true if all parameter value match their respective evaluate trigger parameter. This condition is typically used to run an action or sequence of actions as long as evaluate trigger conditions are true. ^Parameter^Value^Description^ |evaluate.trigger|''true'', ''false''|Trigger expression evaluates to true or false| |evaluate.target.fired|''true'', ''false''|Target is in fired or reset state| |evaluate.target.everFired|''true'', ''false''|Target has been fired at least once or never| This is an example of using this condition: false false evaluate.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 these state machine events. If behavior has non-empty identifier replace ''evaluate'' with ''evaluate(id)''. ===== evaluate.true ===== Trigger expression changed to true. ===== evaluate.false ===== Trigger expression changed to false. ====== 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 not required element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorEvaluate.html,ECBehaviorEvaluate~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Add support to firet target if trigger evaluates to true. ====== Element Class Example ====== This example defines an element which evaluates trigger. class MyElement extends BehaviorElementClass public var ECBehaviorEvaluate evaluate func new() evaluate = ECBehaviorEvaluate.new(this) end end ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: default other second second ventOn ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]