Skip to content

attempt to index local 'states' (a nil value) in function 'can' #3

@k98kurz

Description

@k98kurz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions