Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » GABehaviorFlags
Game app behavior adding flags support to state machines.
Adds actions, conditions and events allowing state machines to set, clear and check named flags. Flags that are not set are considered cleared.
To access this behavior from other application behaviors use GABehaviorFlagsiorStateMachine.getBehaviorInApp(). This behavior can be added only once to a game app.
This behavior adds these state machine actions if state machines are present.
Update flags. Action always succeeds.
| Parameter | Value | Description |
|---|---|---|
| set | string | Set named flag. |
| clear | string | Clear named flag. |
This is an example of setting a flag:
<action name='flags.update'> <parameter name='set'>arrived at target</parameter> </action>
This is an example of setting and clearing a flag in the same action:
<action name='flags.update'> <parameter name='set'>arrived at target</parameter> <parameter name='clear'>stay seated</parameter> </action>
This behavior adds these state machine conditions if state machines are present.
Check flag parameters. Condition returns true if all parameter values match their respective flag state.
| Parameter | Value | Description |
|---|---|---|
| flags.flag | string | Flag to check. |
| flags.set | true, false | Flag is set or not. |
This is an example of using this condition:
<action name='myAction' id='doing something'> <condition>flags.check</condition> <parameter name='flags.flag'>arrived at target</parameter> <parameter name='flags.set'>true</parameter> </action>
This behavior sends these state machine events.
Flag named name changed from cleared to set. The name of the flag is appended to the event name.
This is an example of a transition that runs if the flag “arrived at target” has been set:
<transition event='flags.set:arrived at target' state='nextState'> </transition>
Flag named name changed from set to cleared. The name of the flag is appended to the event name.
This is an example of a transition that runs if the flag “arrived at target” has been cleared:
<transition event='flags.cleared:arrived at target' state='nextState'> </transition>
This behavior requires no other behaviors.
Since DragonScript Module Version 1.35