Testing Different Projects

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
LedLoaf
Prole
Posts: 2
Joined: Thu Apr 08, 2021 7:56 pm

Testing Different Projects

Post by LedLoaf »

Hello,

So I am using ZeroBrane Studio Lua IDE, was really easy to set up. This actually might be a question for them but I thought I'd see if I could get some help here. So you have to have main.lua as your main file correct? I've been doing these tutorials and I like to make new files and save the previous before additions so I can always backtrack the progression of how I ended up at this current source.

How can I test different files without renaming each file to main.lua? I hope that makes sense. For example collision_circles.lua and arrow_follow.lua . Is there a more simple way of running each individual file, without renaming them to main.lua? I'm still learning how to navigate around Lua, so I'm assuming there is a way to just run various lua examples from a main.lua.

Thanks, have a great day.
User avatar
ReFreezed
Party member
Posts: 232
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Testing Different Projects

Post by ReFreezed »

Just have a single line in main.lua where you require() the file you want to run.

Code: Select all

require("collision_circles")
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
LedLoaf
Prole
Posts: 2
Joined: Thu Apr 08, 2021 7:56 pm

Re: Testing Different Projects

Post by LedLoaf »

So 2 files have love.load, load.update, load.draw that will still work?
User avatar
darkfrei
Party member
Posts: 226
Joined: Sat Feb 08, 2020 11:09 pm

Re: Testing Different Projects

Post by darkfrei »

LedLoaf wrote: Sat Apr 10, 2021 2:44 am So 2 files have love.load, load.update, load.draw that will still work?
Something like

Code: Select all

require ("main-old")
-- require ("main-new")
But normally just one folder for every project.
User avatar
ReFreezed
Party member
Posts: 232
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Testing Different Projects

Post by ReFreezed »

Only the files you require() will actually run, so if you only call require("collision_circles") in main.lua then it doesn't matter what arrow_follow.lua or any other file contains as those will not run.

main.lua:

Code: Select all

-- Only uncomment one line:
-- require("collision_circles") -- Uncomment to run the collision_circles.lua file.
-- require("arrow_follow") -- Uncomment to run the arrow_follow.lua file.
collision_circles.lua:

Code: Select all

function love.draw()
	love.graphics.print("collision_circles!!!")
end
arrow_follow.lua:

Code: Select all

function love.draw()
	love.graphics.print("arrow_follow!!!")
end
Tools: Hot Particles, LuaPreprocess, (more)
Games: Momento Temporis: Light from the Deep, Energize!
"If each mistake being made is a new one, then progress is being made."
togFox
Party member
Posts: 164
Joined: Sat Jan 30, 2021 9:46 am

Re: Testing Different Projects

Post by togFox »

I think most ppl just have different folders for different projects and each has a main.lua.
Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests