Simple state switcher class for Love2D / Lua that uses one file per state. It completely covers Love 2D state management for the game developers. Licensed under CC-BY 4.0 / Creative Commons Attribution International 4.0.
stateswitcher.zip (2,7 Kb; for Love2D / Lua)
state.switch("credits") -- switching to credits.lua
Code example with passing a value:
state.switch("credits;2;hello") -- passing 2 as the first value, "hello" as the second value
Code example to retrieve the values passed after switch:
step=passvar -- gets the first value = 2
greeting=passvar -- = "hello"
state.clear() -- clearing the values passed, so no zombie values hang around
- edit your code & save to see changes immediately after state switch (without leaving your program)
- reuse the functions from the previous states (to keep same behaviour) or redeclare the functions (to change behaviour)