Page 1 of 1

LOAD EXTERNAL LUA FILE (Solved!)

Posted: Fri Oct 26, 2018 1:00 am
by Darlex
Example: If i have "something.lua" in C:\things\
How i can load it?

Re: How i can load some external lua file?

Posted: Fri Oct 26, 2018 5:34 am
by ivan
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.

Re: How i can load some external lua file?

Posted: Fri Oct 26, 2018 9:54 am
by pgimeno
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.

Re: How i can load some external lua file?

Posted: Fri Oct 26, 2018 10:48 am
by D0NM
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

Re: How i can load some external lua file?

Posted: Fri Oct 26, 2018 12:46 pm
by milon
If you do want to learn the require function, see my post here:
viewtopic.php?f=3&t=85741#p223173

Re: [SOLVED]

Posted: Sat Dec 08, 2018 2:18 pm
by Darlex
Thanks!

Re: [SOLVED]

Posted: Sat Dec 08, 2018 3:06 pm
by Stifu
Please don't delete your posts... They can be useful to other people later.