Love seems to only run my 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
Empuze
Prole
Posts: 1
Joined: Wed Sep 26, 2012 3:29 pm

Love seems to only run my main.lua

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Love seems to only run my main.lua

Post 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.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Love seems to only run my main.lua

Post 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)
Lua is not an acronym.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Love seems to only run my main.lua

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love seems to only run my main.lua

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 11 guests