Tried this out because it looked cool. Used the following code:
local fsm = require "fsm"
local gamestate = fsm.create({
initial = "loading",
events = {
{ name = "loaded", from = "loading", to = "ready" },
}
})
print(gamestate.current)
if gamestate.can("test") then
gamestate.test()
end
print(gamestate.current)
It is a poor design to crash if an undefined event is passed to the can function. It appears that the purpose of the function is to determine if a given event is valid, not to crash the program if it is not. It should just return false.