So, I'm working on giving the game a menu screen. The way I plan to do it is have separate love callbacks for the two game states: menu state, and play state. However, as I was not really thinking about this last night, I failed to initially define a namespace for the play state, as it was the only state at that point.
I know Lua doesn't natively support namespaces in the traditional sense, so my understanding is that people simply wrap a table around their code and call it a namespace. My only issue is that I'm not sure it will work with my current set up. Here is my dilemma:
Code: Select all
namespace = {
x = 0
y = 0
function A(n) return n end -- Is the key for this 'A' or '1'?
function B() return A(0) end
x = function B() -- Will I be able to call B() while still inside namespace?
}
namespace.x = namespace.B() -- Or will I have to be outside of the declaration before I can do any calls?
I would like to be able wrap the love callbacks in the namespace as well, so that from menu, when the player pushes "PLAY," I can just call the play state's love.load().
Any help would be appreciated. Even if it is a "you're doing it wrong, here is a better way."