Game State Management in LUA

From your description it seems your states will be simple so my advice would be to keep it simple too in the implementation.

Simply have a variable that contain the current state
gameState = "gameplay"

and in your update function simply branch out depending on the variable

if gameState=="gameplay" then
	gameplayUpdate()
elseif gameState=="pause" then
	pauseUpdate()
elseif gameState=="gameover" then
	gameoverUpdate()
end

It's not fancy but you shouldn't be if you don't need to.
This is what I used for a long time and it works fine. When I needed more controls I used a mode manager which handle my states/screen with a stack system.

4 Likes