battlecore::fsm
The fsm module reads and sets the device finite state machine state. Changing the state drives which state handlers run. Include its declarations with include "./battlecore/fsm.bst";.
getState
Returns the name of the current state.
native string battlecore::fsm.getState ();setState
Moves the device to the named state. The optional dataobject arrives on the new state's ENTER event as evt.data, beside oldState and newState.
native void battlecore::fsm.setState (string newVal, object data = {});A script moves the player between the states of play: IN_GAME, DEAD, RESPAWNING, GAME_OVER, and any state the game script declares for itself. A game can add its own states, such as JAIL or STUNNED, by writing a state block for them. The firmware treats them as play: the game clock, the end checks and the radar keep running.
The move only happens while the device is playing, and only into one of those states. Every other state belongs to the firmware: the lobby, the start, the end of the game and HOME. To end the game, call battlecore::game.end, which tells every other device as well.
enum StateEnum {
IN_GAME = "IN_GAME",
JAIL = "JAIL",
}
state StateEnum.JAIL {
module ModuleEnum.FSM {
event EventEnum.ENTER (EventData evt) => {
after 10000 {
battlecore::fsm.setState(StateEnum.IN_GAME);
};
}
}
}