It looks like you're new here. If you want to get involved, click one of these buttons!
local firefly = Firefly.new("firefly1") local stateLightsOn = State.new("LIGHTS_ON") firefly:setState(stateLightsOn) -- then Choice 1 firefly:onEnterState(stateLightsOn) -- or Choice 2 stateLightsOn:onEnter(firefly) |
Comments
http://lua-users.org/wiki/FiniteStateMachine
Actually, there is a modified version of the same thing on GitHub that might be better:
https://github.com/cornelisse/LuaFSM
As it mentions in the text, the beauty of this scheme (courtesy of Lua's table mechanism) is that the states and events can be of any type, including tables and functions if required.
Best regards
Likes: atilim