Page 1 of 1
Calling a previous file
Posted: Wed Sep 16, 2020 7:44 pm
by Lekic
Hello,am trying to run another .lua file but it keeps calling the previous one inside the same folder.what can i do so it stop calling the first one?
Re: Calling a previous file
Posted: Wed Sep 16, 2020 8:15 pm
by Jeeper
Löve will always call your "main.lua" file. If you want to call code inside another file you need to require it.
Below is an example (that assumes you want to reach the shape.lua file).
Code: Select all
require("shape")
function love.load()
end
function love.update(dt)
end
function love.draw()
end
More details here:
https://love2d.org/wiki/require
If you are really new to Löve and lua in general, then I would suggest looking up tutorials. I have a youtube tutorial series that I link in my signature. If you prefer a written tutorial I highly recommend
Sheepolutions free online book.
Re: Calling a previous file
Posted: Wed Sep 16, 2020 8:27 pm
by pgimeno
It's a little problem of Android, you can't use different folders, you're limited to the lovegame folder, or to using .love files. Here's what you can do:
To run several different Lua files in Android, I suggest you have a file called main.lua which only requires the file you want to run and does nothing else. For example, if you want to run shape.lua instead of main.lua, create a main.lua with this content:
If you later want to run something.lua instead of shape.lua, you edit main.lua and change 'shape' to 'something'.