Page 1 of 1

Running separate love files

Posted: Mon Nov 30, 2009 1:34 am
by imyourhero
Hey, I've been digging around through the documentation and whatnot and I can't quite seem to get this to work.

The game I'm working on now is going to have a single player and a multi-player mode, each of which will work slightly different from each other in both the draw and update sections, and require different variables from one another. so essentially, to avoid clutter, the easiest way to handle this seems like it would be like this: Have the main program file essentially be a launcher of some kind, with just a menu, and once you choose single or multi, it runs another LOVE file corresponding to the choice you made. Is this possible? And if so, how?

Thanks in advance!

Re: Running separate love files

Posted: Mon Nov 30, 2009 6:58 am
by Robin
In one word: no.

But overloading draw and update is possible:

Code: Select all

function chooseSinglePlayer()
    update = single.update
    draw = single.draw
end
function chooseMultiPlayer()
    update = multi.update
    draw = multi.draw
end
Then you could put all functions and global variables into the single and multi tables, so that they don't collide with each other.

Re: Running separate love files

Posted: Fri Dec 04, 2009 12:32 am
by imyourhero
Thanks a lot for the help, I've been working with this kind of a structure since you posted it, and it's really getting somewhere. It's much easier to have separate documents for the different phases of the game and then have the game switch around between them. My "main" file was getting a little silly.