Example: If i have "something.lua" in C:\things\
How i can load it?
LOAD EXTERNAL LUA FILE (Solved!)
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
LOAD EXTERNAL LUA FILE (Solved!)
Last edited by Darlex on Mon Jan 07, 2019 8:52 pm, edited 2 times in total.
Hi! I wish you have an amazing day!
Re: How i can load some external lua file?
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.
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?
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?
Our LÖVE Gamedev blog Zabuyaki (an open source retro beat 'em up game). Twitter: @Zabuyaki.
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
LÖVE & Lua Video Lessons in Russian / Видео уроки по LÖVE и Lua
Re: How i can load some external lua file?
If you do want to learn the require function, see my post here:
viewtopic.php?f=3&t=85741#p223173
viewtopic.php?f=3&t=85741#p223173
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Re: [SOLVED]
Please don't delete your posts... They can be useful to other people later.
Zabuyaki, our upcoming beat 'em up: https://www.zabuyaki.com
Who is online
Users browsing this forum: Ahrefs [Bot] and 68 guests