openspace.statemachine
Functions overview
Name |
Documentation |
---|---|
Returns true if there is a defined transition between the current state and the given string name of a state, otherwise false |
|
Creates a state machine from a list of states and transitions |
|
Returns the string name of the current state that the statemachine is in |
|
Destroys the current state machine and deletes all the memory |
|
Triggers a transition from the current state to the state with the given identifier |
|
Returns a list with the identifiers of all the states that can be transitioned to from the current state |
|
Prints information about the current state and possible transitions to the log |
|
Saves the current state machine to a |
|
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.
state
String
Return type: Boolean
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.
states
Table
transitions
Table
startState
String?
Return type: void
openspace.statemachine.createStateMachine(states, transitions, startState)
currentState
Returns the string name of the current state that the statemachine is in.
Return type: String
openspace.statemachine.currentState()
destroyStateMachine
Destroys the current state machine and deletes all the memory.
Return type: void
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.
newState
String
Return type: void
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[]
openspace.statemachine.possibleTransitions()
printCurrentStateInfo
Prints information about the current state and possible transitions to the log.
Return type: void
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.
filename
String
directory
String?
Return type: void
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.
startState
String
Return type: void
openspace.statemachine.setInitialState(startState)