User Tools

Site Tools


dragengine:modules:dragonscript:behavior_toggle

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_toggle [2025/03/19 15:11] – [Behavior Factory] dragonlorddragengine:modules:dragonscript:behavior_toggle [2025/05/04 13:50] (current) – [toggle.check] dragonlord
Line 51: Line 51:
  
 ===== toggled ===== ===== toggled =====
 +
 +Trigger target toggled.
 +
 +====== Behavior Tree Actions ======
 +
 +This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''toggle'' with ''toggle(id)''.
 +
 +===== toggle.set =====
 +
 +Set one or more toggle trigger parameters.
 +
 +^Parameter^Value^Description^
 +|target|''fire'', ''reset'', ''fullReset'', ''toggle''|Fire, reset, full reset or toggle target|
 +
 +This is an example of using this action:
 +<code xml>
 +<action name='toggle.set'>
 +  <parameter name='target'>toggle</parameter>
 +</action>
 +</code>
 +
 +===== toggle.check =====
 +
 +Check one or more toggle trigger parameters. Action succeeds if all parameter value matches their respective toggle trigger parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a toggle 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:
 +<code xml>
 +<sequence>
 +  <action name='toggle.check'>
 +    <parameter name='target.fired'>false</parameter>
 +    <parameter name='target.everFired'>false</parameter>
 +  </action>
 +  <!-- actions here run only if target is in reset state and has been never fired yet -->
 +</sequence>
 +</code>
 +
 +====== Behavior Tree Conditions ======
 +
 +This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''toggle'' with ''toggle(id)''.
 +
 +===== toggle.check =====
 +
 +Check one or more toggle trigger parameters. Conditions returns true if all parameter value match their respective toggle trigger parameter. This condition is typically used to run an action or sequence of actions as long as toggle trigger conditions are true.
 +
 +^Parameter^Value^Description^
 +|toggle.trigger|''true'', ''false''|Trigger expression toggles to true or false|
 +|toggle.target.fired|''true'', ''false''|Target is in fired or reset state|
 +|toggle.target.everFired|''true'', ''false''|Target has been fired at least once or never|
 +
 +This is an example of using this condition:
 +<code xml>
 +<action name='myAction' id='doing something'>
 +  <parameter name='target.fired'>false</parameter>
 +  <parameter name='target.everFired'>false</parameter>
 +  <condition>toggle.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 ''toggle'' with ''toggle(id)''.
 +
 +===== toggle.toggled =====
  
 Trigger target toggled. Trigger target toggled.
Line 60: Line 137:
 ====== 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 103: Line 181:
                    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_toggle.1742397073.txt.gz · Last modified: 2025/03/19 15:11 by dragonlord