Difference between revisions of "Stateswitcher"

Line 23: Line 23:
  
 
{{#set:Name=Stateswitcher}}
 
{{#set:Name=Stateswitcher}}
{{#set:LOVE Version=0.9.1}}
+
{{#set:LOVE Version=Any (tested with 0.9.1)}}
 
{{#set:Description=A state switcher library based on files (one file=one state).}}
 
{{#set:Description=A state switcher library based on files (one file=one state).}}
 
[[Category:Libraries]]
 
[[Category:Libraries]]

Revision as of 02:56, 6 May 2014

Simple state switcher class for Love2D / Lua that uses one file per state.

Download: Stateswitcher class

Code example:

state=require("stateswitcher")
state.switch("credits") -- switching to credits.lua

Code example with passing a value:

state=require("stateswitcher")
state.switch("credits;2;hello") -- passing 2 as the first value, "hello" as the second value

Other advantages:

- 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)

- automate debugging - create a sequence of state switching with variables passed