openspace.statemachine

Functions overview

Name

Documentation

canGoToState

Returns true if there is a defined transition between the current state and the given string name of a state, otherwise false

createStateMachine

Creates a state machine from a list of states and transitions

currentState

Returns the string name of the current state that the statemachine is in

destroyStateMachine

Destroys the current state machine and deletes all the memory

goToState

Triggers a transition from the current state to the state with the given identifier

possibleTransitions

Returns a list with the identifiers of all the states that can be transitioned to from the current state

printCurrentStateInfo

Prints information about the current state and possible transitions to the log

saveToDotFile

Saves the current state machine to a

setInitialState

Immediately sets the current state to the state with the given name, if it exists

Functions

canGoToState

Returns true if there is a defined transition between the current state and the given string name of a state, otherwise false.

Parameters
  • state String

Return type: Boolean

Signature
openspace.statemachine.canGoToState(state)

createStateMachine

Creates a state machine from a list of states and transitions. See State and Transition documentation for details. The optional thrid argument is the identifier of the desired initial state. If left out, the first state in the list will be used.

Parameters
  • states Table

  • transitions Table

  • startState String?

Return type: void

Signature
openspace.statemachine.createStateMachine(states, transitions, startState)

currentState

Returns the string name of the current state that the statemachine is in.

Return type: String

Signature
openspace.statemachine.currentState()

destroyStateMachine

Destroys the current state machine and deletes all the memory.

Return type: void

Signature
openspace.statemachine.destroyStateMachine()

goToState

Triggers a transition from the current state to the state with the given identifier. Requires that the specified string corresponds to an existing state, and that a transition between the two states exists.

Parameters
  • newState String

Return type: void

Signature
openspace.statemachine.goToState(newState)

possibleTransitions

Returns a list with the identifiers of all the states that can be transitioned to from the current state.

Return type: String[]

Signature
openspace.statemachine.possibleTransitions()

printCurrentStateInfo

Prints information about the current state and possible transitions to the log.

Return type: void

Signature
openspace.statemachine.printCurrentStateInfo()

saveToDotFile

Saves the current state machine to a .dot file as a directed graph. The resulting graph can be rendered using external tools such as Graphviz. The first parameter is the name of the file, and the second is an optional directory. If no directory is given, the file is saved to the temp folder.

Parameters
  • filename String

  • directory String?

Return type: void

Signature
openspace.statemachine.saveToDotFile(filename, directory)

setInitialState

Immediately sets the current state to the state with the given name, if it exists. This is done without doing a transition and completely ignores the previous state.

Parameters
  • startState String

Return type: void

Signature
openspace.statemachine.setInitialState(startState)