[RESOLVED] getfenv and setfenv alternative?
[RESOLVED] getfenv and setfenv alternative?
Hello, i was wondering if there was a workaround for using getfenv and setfenv, so i can add support for letting users adding basic lua code to their machines. If i cant use get/setfenv, then it will expose all game functions to the user, winch i was wanting to limit that with those functions.
Last edited by rater193 on Sat Apr 22, 2017 8:53 pm, edited 2 times in total.
Re: getfenv and setfenv alternative?
wow, that worksDaveMcW wrote:The 4th argument to load() is what you want.
https://www.lua.org/manual/5.2/manual.html#pdf-load


Re: getfenv and setfenv alternative?
DaveMcW wrote:The 4th argument to load() is what you want.
https://www.lua.org/manual/5.2/manual.html#pdf-load
how would i write to a file?
Re: getfenv and setfenv alternative?
btw, i managed to get this to work 
im happy about that
thx again for the help, i didnt know that load was a part of ACTUAL lua lol

Code: Select all
/c local ret, err = load('local test = 1 print("load: "..tostring(load))', "", "bt", {["print"] = game.player.print, ["tostring"] = tostring})() game.player.print(tostring(ret)..", "..tostring(err))
