User Tools

Site Tools


dragengine:modules:dragonscript:behavior_evaluate

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)
    <string name='evaluate.trigger'>@switchOnVent & @powerEnabled</string>

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)
    <string name='evaluate.target'>ventOn</string>

pulse

Pulse target instead of toggle fired state.

  • Full name: evaluate.pulse or evaluate({id}).pulse
  • Type: boolean
  • Default Value: false
  • Example (*.deeclass)
    <boolean name='evaluate.pulse'>true</boolean>

Events

evaluatesTrue

Trigger expression changed to true.

evaluatesFalse

Trigger expression changed to false.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

This behavior does not support optional behaviors.

Persistency

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

API Documentation

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorEvaluate'>
    <!-- optional: use BaseGameApp trigger table. game can add more supported values.
                   default is 'default' -->
    <string name='triggerTable'>default</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <string name='.target'>ventOn</string>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorEvaluate' id='second'/>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_evaluate.txt · Last modified: 2025/03/13 17:16 by dragonlord