Posted 09 July 2013 - 06:45 AM
I'm creating a debug console, so I can run lua commands without modifying the script itself.
Pressing a key will bring up an input, where you can type a command and it should run it
as if it were in the script.
I've taken an example from the "rom/programs/lua", but I cannot get the pcall function know
anything about from the caller of the pcall. Sounds incomprehensible? In my script, there's a function
called pause(). When this snippet calls the function I typed into the debug console:
The line is ran properly, but it doesn't know what is "pause()" and returns error "attempt to call nil".
I've tried stuff like this right before the pcall line:
but it doesn't work. How can I get it to work?
Pressing a key will bring up an input, where you can type a command and it should run it
as if it were in the script.
I've taken an example from the "rom/programs/lua", but I cannot get the pcall function know
anything about from the caller of the pcall. Sounds incomprehensible? In my script, there's a function
called pause(). When this snippet calls the function I typed into the debug console:
local result = {pcall(function() return func() end)}
The line is ran properly, but it doesn't know what is "pause()" and returns error "attempt to call nil".
I've tried stuff like this right before the pcall line:
local env = getfenv()
setfenv(func, env)
but it doesn't work. How can I get it to work?