GameState table

I remember seeing a way to keep track of game states in a table, but can’t seem to find it. Could anyone give me a link or example? Thanks

Heres one I wrote about

https://coolcodea.wordpress.com/2013/05/04/47-game-template/

Just make a class for each state, and put them in a table:

states = {
    menu = Menu(),
    game = Game(),
}

Then make a state variable that stores which state is the current one. So you could do state = "game" to set it to the game state.

In draw, touched, etc. just use something like

function draw()
    states[state]:draw()
end

Thanks, that’s exactly what I was looking for SkyTheCoder

I found this scene manager example to be HUGELY helpful to me:

http://codea.io/talk/discussion/677/scenemanager/p1

It really helped me organise the game I’m working on.