This module provides a classical mealy/moore state machine.
Each machine in constructed by calling new() States and Transitions are lazily added to the machine as transition handlers and state tick handlers are registered. However the state machine must be fully defined after init is done. Dynamic machine changes are currently unsupported An example usage can be found here: map_gen\combined\tetris\control.lua
utils.debug |
Module.transition(self, new_state) | Transitions the supplied machine into a given state and executes all transaction_callbacks |
Module.in_state(self, state) | Is this machine in this state? |
Module.machine_tick(self) | Invoke a machine tick. |
Module.register_state_tick_callback(self, state, callback) | Register a handler that will be invoked by StateMachine.machine_tick You may register multiple handlers for the same transition NOTICE: This function will invoke an error if called after init. |
Module.register_transition_callback(self, old, new, callback) | Register a handler that will be invoked by StateMachine.transition You may register multiple handlers for the same transition NOTICE: This function will invoke an error if called after init. |
Module.new(init_state) | Constructs a new state machine |
Transitions the supplied machine into a given state and executes all transaction_callbacks
Parameters:Is this machine in this state?
Parameters:Invoke a machine tick.
Will execute all in_state_callbacks of the given machine
Parameters:Register a handler that will be invoked by StateMachine.machine_tick You may register multiple handlers for the same transition NOTICE: This function will invoke an error if called after init.
Dynamic machine changes are currently unsupported
Parameters:Register a handler that will be invoked by StateMachine.transition You may register multiple handlers for the same transition NOTICE: This function will invoke an error if called after init.
Dynamic machine changes are currently unsupported
Parameters:Constructs a new state machine
Parameters: