Spajk Posted April 10, 2014 Share Posted April 10, 2014 I'd like to run certain code via loadstring in an empty envirovment without any MTA or Lua functions. Could anyone who fully understands how Lua envirovments work help me? Link to comment
arezu Posted April 11, 2014 Share Posted April 11, 2014 Why would you want to do this? Anyways, an environment refers to a table from which variables are read from when using variables, and written to when saving variables. So an empty environment refers to an environment where there are no variables to start with. local code = [[put your code here, or load from file or whatever]] local env = {} --env._G = env -- use only if you have variables to put in env at start, so that _G.varName can be used if there is a need for it local func = loadstring(code) setfenv(func, env) pcall(func) This website has very good examples and explanations on how to use certain functions in lua: http://www.gammon.com.au/scripts/doc.php?lua=setfenv Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now