SDK 1.9.1 Mac
Per the docs, the entire Lua 5.4 API should be available.
I'm having trouble calling the load function.
Code sample inspired by this stackoverflow answer:
local func, err = load("return function(a,b) return a+b end")
if func then
local ok, add = pcall(func)
if ok then
print(add(2,3))
else
print("Execution error:", add)
end
else
print("Compilation error:", err)
end
This should print 5
, but this is the Simulator console output:
level.lua:32: bad argument #2 to 'load' (number expected, got no value)
stack traceback:
[C]: in function 'load'
level.lua:32: in function 'LoadFile'
main.lua:6: in function 'startGame'
[C]: in function 'xpcall'
main.lua:10: in main chunk
main.lua:15: level.lua:32: bad argument #2 to 'load' (number expected, got no value)
stack traceback:
[C]: in function 'error'
main.lua:15: in main chunk
main.lua:15: level.lua:32: bad argument #2 to 'load' (number expected, got no value)
stack traceback:
[C]: in function 'error'
main.lua:15: in main chunk
main.lua:15: level.lua:32: bad argument #2 to 'load' (number expected, got no value)
stack traceback:
[C]: in function 'error'
main.lua:15: in main chunk
Argument #2 should be optional, and also not be a number but a string (parameter chunkname)
Is this a bug in the SDK?