Code: Select all
arg = "Non-code"
if arg then
ok, res = pcall(assert(loadstring(arg)))
if ok then
-- say(channel, "Code executed!")
else
-- say(channel, "Error occurred: " ..res)
end
end
When running this code, arg is executed in the main chunk, and thus crashing löve.
Running any 'correct' code works fine, I.E. "print('Hello world!')"
The issue is that pcall is being 'faulty' ; when correct code is ran, the ok and res variables are 'returned' by pcall however.
Does anybody know what I did wrong, and how I can correct my error?