G.getfenv

From GMod Wiki

Revision as of 21:48, 2 November 2009 by Crazy Quebecer (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax getfenv( Function Affected Function : Integer Stack Level )
Where is this used?
Description:
Returns what the given function sees as the global environment. By default this will be _G.
Returns: Table The Environment
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.getfenv]G.getfenv [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDemonstrates what the function does.
Used onNewerShared.png
Code
 
a = 10				-- A Global Variable
 
local G = getfenv( 1 )		-- Gets the current environment and stores it into 'G'.
 
print(G.a)			--> 10 , ( since 'G' now holds the current environment we can reference 'a' from inside it )
 
Output10.


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox