Page 1 of 1

Testing Different Projects

Posted: Thu Apr 08, 2021 8:02 pm
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.

Re: Testing Different Projects

Posted: Fri Apr 09, 2021 6:23 pm
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")

Re: Testing Different Projects

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

Re: Testing Different Projects

Posted: Sat Apr 10, 2021 5:20 am
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.

Re: Testing Different Projects

Posted: Sat Apr 10, 2021 6:38 am
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

Re: Testing Different Projects

Posted: Sun Apr 11, 2021 12:22 pm
by togFox
I think most ppl just have different folders for different projects and each has a main.lua.