When I run the game, I can only visit a state once.
For example, when I start the game, I am led to the state "meny" (the main menu). From that state I can simply go to another state called "LevelSelect" (a level selecting menu). from that state I have buttons linked to all other states in the game (including the meny state), but I cannot go to the meny state because i already have loaded it. If I try to do that, the LevelSelect state will reload instead. It do not matter which state I am on or which state i try to load.
I have a main main.lua that I load the states from. It looks a bit like this:
Code: Select all
function loadState(name)
state = {}
local path = "states/" .. name
require(path .. "/main")
load()
end
function load()
end
function love.load()
loadState("meny")
end