Calling a previous file

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Lekic
Prole
Posts: 5
Joined: Tue Sep 15, 2020 9:56 pm

Calling a previous file

Post 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?
Attachments
Screenshot_20200916-203857.png
Screenshot_20200916-203857.png (91.62 KiB) Viewed 3903 times
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Calling a previous file

Post 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.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Calling a previous file

Post 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:

Code: Select all

require 'shape'
If you later want to run something.lua instead of shape.lua, you edit main.lua and change 'shape' to 'something'.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests