User Tools

Site Tools


dragengine:modules:dragonscript:behavior_timer

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_timer [2025/03/19 15:10] – [Behavior Factory] dragonlorddragengine:modules:dragonscript:behavior_timer [2025/05/04 13:49] (current) – [timer.check] dragonlord
Line 124: Line 124:
  
 ===== timerCancelled ===== ===== timerCancelled =====
 +
 +Timer cancelled.
 +
 +====== Behavior Tree Actions ======
 +
 +This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''timer'' with ''timer(id)''.
 +
 +===== timer.set =====
 +
 +Set one or more timer trigger parameters.
 +
 +^Parameter^Value^Description^
 +|target|''fire'', ''reset'', ''fullReset''|Fire, reset or full reset target|
 +|timer|''arm'', ''cancel'', ''rearm'', ''timeout''|<WRAP>
 +  * ''arm'': Arm timer if not running
 +  * ''cancel'': Cancel timer if running
 +  * ''rearm'': Cancel timer then arm it
 +  * ''timeout'': Cancel timer then trigger timeout
 +</WRAP>|
 +
 +This is an example of using this action:
 +<code xml>
 +<action name='timer.set'>
 +  <parameter name='target'>reset</parameter>
 +  <parameter name='timer'>rearm</parameter>
 +</action>
 +</code>
 +
 +===== timer.check =====
 +
 +Check one or more timer trigger parameters. Action succeeds if all parameter value matches their respective timer trigger parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a timer 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|
 +|running|''true'', ''false''|Timer is running|
 +|remaining.less|float|Remaining timer time is less than value in seconds|
 +|remaining.greater|float|Remaining timer time is greater than value in seconds|
 +|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:
 +<code xml>
 +<sequence>
 +  <action name='timer.check'>
 +    <parameter name='running'>true</parameter>
 +    <parameter name='remaining.less'>3</parameter>
 +  </action>
 +  <!-- actions here run only if timer is running with less than 3 seconds remaining -->
 +</sequence>
 +</code>
 +
 +====== Behavior Tree Conditions ======
 +
 +This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''timer'' with ''timer(id)''.
 +
 +===== timer.check =====
 +
 +Check one or more timer trigger parameters. Conditions returns true if all parameter value match their respective timer trigger parameter. This condition is typically used to run an action or sequence of actions as long as timer trigger conditions are true.
 +
 +^Parameter^Value^Description^
 +|timer.trigger|''true'', ''false''|Trigger expression timers to true or false|
 +|timer.target.fired|''true'', ''false''|Target is in fired or reset state|
 +|timer.target.everFired|''true'', ''false''|Target has been fired at least once or never|
 +|timer.running|''true'', ''false''|Timer is running|
 +|timer.remaining.less|float|Remaining timer time is less than value in seconds|
 +|timer.remaining.greater|float|Remaining timer time is greater than value in seconds|
 +
 +This is an example of using this condition:
 +<code xml>
 +<action name='myAction' id='doing something'>
 +  <parameter name='timer.running'>true</parameter>
 +  <parameter name='timer.remaining.less'>3</parameter>
 +  <condition>timer.check</condition>
 +</action>
 +</code>
 +
 +====== 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 ''timer'' with ''timer(id)''.
 +
 +===== timer.started =====
 +
 +Timer started.
 +
 +===== timer.elapsed =====
 +
 +Timer elapsed.
 +
 +===== timer.cancelled =====
  
 Timer cancelled. Timer cancelled.
Line 133: Line 231:
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
  
-This behavior does not support 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 ====== ====== Persistency ======
  
Line 178: Line 276:
                    string to not synchronize. default is empty string. -->                    string to not synchronize. default is empty string. -->
     <string name='trigger.synchronize'>other</string>     <string name='trigger.synchronize'>other</string>
 +    
 +    <!-- optional: use behavior tree with id instead of empty string -->
 +    <string name='behaviorTree'>second</string>
 +    
 +    <!-- optional: use state machine with id instead of empty string -->
 +    <string name='stateMachine'>second</string>
          
     <!-- set element properties. omit property prefix if used inside behavior tag -->     <!-- set element properties. omit property prefix if used inside behavior tag -->
dragengine/modules/dragonscript/behavior_timer.1742397058.txt.gz · Last modified: 2025/03/19 15:10 by dragonlord