Page 1 of 1

Documentation discuss about love.load

Posted: Mon Apr 04, 2011 8:57 pm
by TsT
Hello

The wiki said ( http://love2d.org/wiki/Tutorial:Callback_Functions )
This function gets called only once, when the game is started, and is usually where you would load resources, initialize variables and set specific settings. All those things can be done anywhere else as well, but doing them here means that they are done once only, saving a lot of system resources.
I remember a way to pause/resume and reload the game in LOVE v0.5.0.
I suppose the reload feature has disappeared in 0.7.1, no problem.
But I don't anderstand how you can "saving a lot of system resources".
If I wrote a main.lua like :

Code: Select all

myvar = "test"
or

Code: Select all

function love.load()
myvar = "test"
end
What the resource differences ?
Is it really "a lot" ?

EDIT: subject edited

Re: Documentation discuss

Posted: Mon Apr 04, 2011 9:10 pm
by kikito
I think that intends to mean that "creating resources only once saves a lot of system resources". The opposite would be creating a font on each frame, inside love.update.

But the wording is a bit unfortunate IMHO.

The only difference I can think of between doing it inside love.load and at the top of your main is that you may have a custom love.run function that doesn't call love.load.

Re: Documentation discuss

Posted: Tue Apr 05, 2011 12:09 am
by BlackBulletIV
A nice thing about a love.load is that it's called after everything is loaded. So you can place it anywhere inside your main.lua file (or even another file), and it will have proper access to all globals and and that stuff.

But anyway, back on topic. That wording is unfortunate. I agree with kikto that it's probably meaning, "don't put it in something that's called regularly", like love.update or love.draw.

Re: Documentation discuss

Posted: Tue Apr 05, 2011 6:28 am
by bartbes
Another thing is, that it can help simulate the old reload feature. If all initializing is done in love.load, calling love.load() should be the same as restarting.