Calling a previous file
Calling a previous file
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
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).
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.
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
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
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'.
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:
Code: Select all
require 'shape'
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 3 guests