Jump to content

Empty envirovment


Recommended Posts

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) 

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...