User Tools

Site Tools


dragengine:modules:dragonscript:gabehavior_flags

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.

State Machine Actions

This behavior adds these state machine actions if state machines are present.

flags.update

Update flags. Action always succeeds.

ParameterValueDescription
setstringSet named flag.
clearstringClear 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>

State Machine Conditions

This behavior adds these state machine conditions if state machines are present.

flags.check

Check flag parameters. Condition returns true if all parameter values match their respective flag state.

ParameterValueDescription
flags.flagstringFlag to check.
flags.settrue, falseFlag 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>

State Machine Events

This behavior sends these state machine events.

flags.set:<name>

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>

flags.cleared:<name>

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>

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

  • GABehaviorStateMachine: Add actions and conditions for state machine to use and events to send to the state machine.

API Documentation

GABehaviorFlags.

Since DragonScript Module Version 1.35

Use Cases

  • Remember that an event has happened.
  • Share a yes/no state between state machines.
  • Wait until another part of the game sets a flag before continuing.

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/gabehavior_flags.txt · Last modified: by dragonlord