Page 1 of 1

Love seems to only run my main.lua

Posted: Wed Sep 26, 2012 3:33 pm
by Empuze
Hello! I downloaded Love last night and recently got round to starting to learn the language. I was following the website tutorials and realised something was wrong, if I made another file such as "conf.lua" it wouldn't register. I was following a tutorial on youtube and did EXACTLY everything he did, and love didn't execute the code I told it to in my conf.lua, but it DID execute the code in main.lua


I would really appreciate help, thanks guys.

Re: Love seems to only run my main.lua

Posted: Wed Sep 26, 2012 4:30 pm
by Roland_Yonaba
Well, conf.lua is supposed to be a configuration file. Yes, you can put some code here, but you're not supposed to.
If conf.lua exists, love loads it, then looks for main.lua and starts running it.
Maybe you should post a .love file, it'll be easier to help.

Re: Love seems to only run my main.lua

Posted: Wed Sep 26, 2012 6:53 pm
by qaisjp
Roland_Yonaba wrote:Well, conf.lua is supposed to be a configuration file. Yes, you can put some code here, but you're not supposed to.
If conf.lua exists, love loads it, then looks for main.lua and starts running it.
Maybe you should post a .love file, it'll be easier to help.
Yeah, post a .love file - the conf.lua shouldn't have any code that shows an output to the player or is involved with game mechanics.
The best use of conf.lua is to treat it as a utility file, putting utility functions (such as math.wrap, math.clamp, split, explode etc)

Re: Love seems to only run my main.lua

Posted: Wed Sep 26, 2012 9:16 pm
by Lafolie
If you want code in another file to run you should use:

Code: Select all

require "script"
Where script is the name of the file, without an extension.

Re: Love seems to only run my main.lua

Posted: Thu Sep 27, 2012 10:42 pm
by Robin
qaisjp wrote:The best use of conf.lua is to treat it as a utility file, putting utility functions (such as math.wrap, math.clamp, split, explode etc)
What? No! Please don't put anything other than love.conf in conf.lua.

People who read your code will start in main.lua, looking up functions that called but not defined there in the files that are required. conf.lua is loaded in boot.lua, but that's in the LÖVE core, so people will likely not check that.

TL;DR: whatever you put in conf.lua is basically invisible.