LUA 'require' usage

Jarod

Member
Joined
Dec 13, 2011
Messages
169
Reaction score
0
Points
16
So, I was fooling around with Lua and I had a little surprise.
Code:
require "test"
is working but
Code:
f = "test"
require f
is not.
Why is that ? Is there a way to obtain something similar ?
The purpose :
I made a MFD and it needs some custom Lua code depending on the ship.
I don't want to make a INI file with the need to parse it, as the Lua code will mostly be conditions using Lua functions and not just var == given value.
Please help :hailprobe:
 
Require is for loading Lua modules, not just simple files, you use:

Code:
f = assert(loadfile(filename))
x = f()

for executing code from a file as a function.
 
Thanks, for my defense I was writing the file as a module, but the correct usage was not require f but require(f).
 
Back
Top