Purpose of love.load() vs top of main.lua

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
ernmalley
Prole
Posts: 2
Joined: Thu Apr 27, 2023 5:44 am

Purpose of love.load() vs top of main.lua

Post by ernmalley »

The love documentation does not make it clear when you should use the love.load() callback versus just putting your initialization code at the top of the main.lua file. I know that love.load gives you access to the command line arguments and that you can declare local variables that will be accessible throughout the various callbacks at the top of the script but not in love.load, but apart from that, what is the difference?
I suppose my point is, what is the use of love.load() apart from giving access to the command line arguments?
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Purpose of love.load() vs top of main.lua

Post by slime »

love.load had more of a purpose in some older love versions because some things used to be initialized after main.lua is loaded and before love.load is called. But most or all of those have been changed to initialize earlier in modern love versions, so love.load isn't too useful these days if you don't need parsed command line arguments. (the global arg table also has un-parsed CLI args.)
ernmalley
Prole
Posts: 2
Joined: Thu Apr 27, 2023 5:44 am

Re: Purpose of love.load() vs top of main.lua

Post by ernmalley »

Thanks for the clarification.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest