|
>I was wondering if it was possible from standard lua to set the global >environment to another table prior to a dofile(), then kill the temp one >and restore the main? Sure. In Lua 4 do do local newG={ fill here with what is needed in the sandbox } local oldG=globals(newG) oldG.dofile(xxx) oldG.globals(oldG) endThanks for the tip... I had problems with this at first until I realized I had to put all the functions I wanted to use into the new environment like:do local newG = {} newG.write = write
oops, the following line:
newG._OUTPUT = write
should have been: newG._OUTPUT = _OUTPUT
newG._ERRORMESSAGE = _ERRORMESSAGE newG._ALERT = _ALERT local oldG = globals(newG) oldG.dofile(xxx) oldG.globals(oldG) end
-joe