Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
k98kurz opened this issue Sep 16, 2023 · 0 comments · May be fixed by #4
Open

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

k98kurz opened this issue Sep 16, 2023 · 0 comments · May be fixed by #4

Comments

@k98kurz
Copy link

k98kurz commented Sep 16, 2023

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.

@k98kurz k98kurz linked a pull request Sep 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant