## Calling a previous file

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

### 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?
Attachments
Screenshot_20200916-203857.png (91.62 KiB) Viewed 1154 times

Jeeper
Party member
Posts: 576
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

### 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).

Code: Select all

require("shape")

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.

pgimeno
Party member
Posts: 2311
Joined: Sun Oct 18, 2015 2:58 pm

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

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'.

### Who is online

Users browsing this forum: No registered users and 17 guests