Running separate love files

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
imyourhero
Prole
Posts: 6
Joined: Mon Nov 09, 2009 6:02 am

Running separate love files

Post 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!
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Running separate love files

Post 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.
Help us help you: attach a .love.
imyourhero
Prole
Posts: 6
Joined: Mon Nov 09, 2009 6:02 am

Re: Running separate love files

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 84 guests