[SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Darlex
Citizen
Posts: 52
Joined: Sun Sep 24, 2017 10:02 am
Contact:

[SOLVED]

Post by Darlex » Fri Oct 26, 2018 1:00 am

SOLVED
Last edited by Darlex on Sat Dec 08, 2018 2:17 pm, edited 1 time in total.
ERROR

User avatar
ivan
Party member
Posts: 1363
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: How i can load some external lua file?

Post by ivan » Fri Oct 26, 2018 5:34 am

Your game shouldn't load code from arbitrary locations - it's NOT safe to do that.
Furthermore "C:/" doesn't mean anything across other platforms like Linux and Android. You want your game to be cross platform, right?
Custom files could be loaded from the "AppData" folder but even that has to be done cautiously, preferably using sandboxing/setenv.
There may be workarounds and hacks, but generally speaking you want to keep your source code inside your game folder.

User avatar
pgimeno
Party member
Posts: 1366
Joined: Sun Oct 18, 2015 2:58 pm

Re: How i can load some external lua file?

Post by pgimeno » Fri Oct 26, 2018 9:54 am

Ivan is right, but there are use cases for loading a Lua file from an arbitrary location. dofile("c:/things/something.lua") will load it, but note that if you execute it multiple times, it will be loaded multiple times. That's a difference with require(), which only loads it once.
Thrust II Reloaded - GifLoad for Löve - GSpöt GUI - My NotABug.org repositories - portland (mobile orientation)
The MS-Github repositories I had have been closed after the acquisition announcement and will be removed in the near future.

User avatar
D0NM
Party member
Posts: 203
Joined: Mon Feb 08, 2016 10:35 am
Location: Zabuyaki
Contact:

Re: How i can load some external lua file?

Post by D0NM » Fri Oct 26, 2018 10:48 am

Darlex wrote:
Fri Oct 26, 2018 1:00 am
Example: If i have "something.lua" in C:\things\
How i can load it?
use this function
https://love2d.org/wiki/love.filesystem.load
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Follow @Zabuyaki.
Twitter @FaMeSoft / GP32 Free Platformer: SUPER PLUSHA
:joker: LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua :joker:

milon
Prole
Posts: 48
Joined: Thu Jan 18, 2018 9:14 pm

Re: How i can load some external lua file?

Post by milon » Fri Oct 26, 2018 12:46 pm

If you do want to learn the require function, see my post here:
viewtopic.php?f=3&t=85741#p223173

User avatar
Darlex
Citizen
Posts: 52
Joined: Sun Sep 24, 2017 10:02 am
Contact:

Re: [SOLVED]

Post by Darlex » Sat Dec 08, 2018 2:18 pm

Thanks!
ERROR

User avatar
Stifu
Citizen
Posts: 60
Joined: Mon Mar 14, 2016 9:53 am
Contact:

Re: [SOLVED]

Post by Stifu » Sat Dec 08, 2018 3:06 pm

Please don't delete your posts... They can be useful to other people later.
Zabuyaki, our upcoming beat 'em up: https://www.zabuyaki.com

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests