Documentation discuss about love.load

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
User avatar
TsT
Party member
Posts: 161
Joined: Thu Sep 25, 2008 7:04 pm
Location: France
Contact:

Documentation discuss about love.load

Post by TsT » Mon Apr 04, 2011 8:57 pm

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
Last edited by TsT on Tue Apr 05, 2011 5:10 pm, edited 1 time in total.
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)

User avatar
kikito
Inner party member
Posts: 3152
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Documentation discuss

Post by kikito » Mon Apr 04, 2011 9:10 pm

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.
When I write def I mean function.

User avatar
BlackBulletIV
Inner party member
Posts: 1260
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Documentation discuss

Post by BlackBulletIV » Tue Apr 05, 2011 12:09 am

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.

User avatar
bartbes
Sex machine
Posts: 4944
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Documentation discuss

Post by bartbes » Tue Apr 05, 2011 6:28 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests