getfenv

Returns the current environment table

Prototype

t = getfenv (f)

Description

Returns the current environment used by the nominated function f.
f can be a function or a number representing the stack level, where 1 is the currently running function, 2 is its parent and so on.

The environment is where "global" variables are stored.

print (getfenv (1)) --> table: 02072780
print (_G) --> table: 02072780
The default for f is 1 (the current function).

Lua functions

Topics