User Tools

Site Tools


dragengine:modules:dragonscript:behavior_statemachine

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_statemachine [2025/03/11 18:54] dragonlorddragengine:modules:dragonscript:behavior_statemachine [2025/05/09 19:04] (current) dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorStateMachine**+[[: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]] >> **ECBehaviorStateMachine**
 </WRAP> </WRAP>
  
Line 44: Line 44:
 ===== path ===== ===== path =====
 Set path to state machine file to load. Set path to state machine file to load.
-  * Full name: ''stateMachine.value'' or ''stateMachine({id}).value''+  * Full name: ''stateMachine.path'' or ''stateMachine({id}).path''
   * Type: string   * Type: string
   * Default Value: empty string   * Default Value: empty string
   * Expected File Type: ''*.desm''   * Expected File Type: ''*.desm''
-  * Example (*.deeclass) <code xml><string name='stateMachine.value'>actor.desm</string></code>+  * Example (*.deeclass) <code xml><string name='stateMachine.path'>actor.desm</string></code> 
 + 
 +===== debug ===== 
 +Debug mode prefix. If not empty string enables debug mode with prefix to locate log messages easily. 
 +  * Full name: ''stateMachine.debug'' or ''stateMachine({id}).debug'' 
 +  * Type: string 
 +  * Default Value: empty string 
 +  * Example (*.deeclass) <code xml><string name='stateMachine.debug'>Debug-Actor-SM</string></code>
  
 ===== Events ===== ===== Events =====
  
 This behavior has no events. This behavior has no events.
 +
 +====== Behavior Tree Actions ======
 +
 +This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace ''stateMachine'' with ''stateMachine(id)''.
 +
 +===== stateMachine.set =====
 +
 +Set one or more state machine parameters.
 +
 +^Parameter^Value^Description^
 +|reset| |Set state machine root state as current state|
 +|state|string|Set state machine state to state with identifier matching string value|
 +
 +This is an example of using this action:
 +<code xml>
 +<action name='stateMachine.set'>
 +  <parameter name='state'>open</parameter>
 +</action>
 +</code>
 +
 +===== stateMachine.event =====
 +
 +Run event on state machine.
 +
 +^Parameter^Value^Description^
 +|id|string|Identifier of event to run|
 +
 +This is an example of using this action:
 +<code xml>
 +<action name='stateMachine.event'>
 +  <parameter name='id'>open door</parameter>
 +</action>
 +</code>
 +
 +===== stateMachine.check =====
 +
 +Check one or more state machine parameters. Action succeeds if all parameter value matches their respective state machine parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a state machine parameter matches (or not).
 +
 +^Parameter^Value^Description^
 +|state|string|Current state identifier matches string value|
 +|state.not|string|Current state identifier does not match string value|
 +|state.starts|string|Current state identifier starts with string value|
 +|state.starts.not|string|Current state identifier does not start with string value|
 +|state.ends|string|Current state identifier ends with string value|
 +|state.ends.not|string|Current state identifier does not end with string value|
 +|state.contains|string|Current state identifier contains string value|
 +|state.contains.not|string|Current state identifier does not contain string value|
 +|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='stateMachine.check'>
 +    <parameter name='state'>open</parameter>
 +  </action>
 +  <!-- actions here run only if state machine is in the "open" state -->
 +</sequence>
 +</code>
 +
 +====== Behavior Tree Conditions ======
 +
 +This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace ''stateMachine'' with ''stateMachine(id)''.
 +
 +===== stateMachine.check =====
 +
 +Check one or more state machine parameters. Conditions returns true if all parameter value match their respective state machine parameter. This condition is typically used to run an action or sequence of actions as long as state machine conditions are true.
 +
 +^Parameter^Value^Description^
 +|stateMachine.state|string|Current state identifier matches string value|
 +|stateMachine.state.not|string|Current state identifier does not match string value|
 +|stateMachine.state.starts|string|Current state identifier starts with string value|
 +|stateMachine.state.starts.not|string|Current state identifier does not start with string value|
 +|stateMachine.state.ends|string|Current state identifier ends with string value|
 +|stateMachine.state.ends.not|string|Current state identifier does not end with string value|
 +|stateMachine.state.contains|string|Current state identifier contains string value|
 +|stateMachine.state.contains.not|string|Current state identifier does not contain string value|
 +
 +This is an example of using this condition:
 +<code xml>
 +<action name='myAction' id='doing something'>
 +  <parameter name='stateMachine.state'>open</parameter>
 +  <condition>stateMachine.check</condition>
 +</action>
 +</code>
  
 ====== Required Behaviors ====== ====== Required Behaviors ======
Line 60: Line 151:
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
  
-This behavior does not support optional behaviors.+  * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: Add actions and conditions for behavior trees to use.
  
 ====== Persistency ====== ====== Persistency ======
dragengine/modules/dragonscript/behavior_statemachine.1741719242.txt.gz · Last modified: 2025/03/11 18:54 by dragonlord