Lua "arg" variable not working (SOLVED)

We use LuaJIT for all platforms but iOS 64 and HTML5. The LuaJIT FAQ reads:

“Q: Why do I get this error: “attempt to index global ‘arg’ (a nil value)”?
Q: My vararg functions fail after switching to LuaJIT!
LuaJIT is compatible to the Lua 5.1 language standard. It doesn’t support the implicit arg parameter for old-style vararg functions from Lua 5.0.
Please convert your code to the Lua 5.1 vararg syntax.”

You can get the arguments in two ways:

function foo(...)
   local args = {...}
   print(args[1])
   print(select(1, ...))
end
2 Likes