Getfenv: Difference between revisions

From GiderosMobile
No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
<languages />
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
'''Class:''' [[(global)]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/(global)|(global)]]<br/>


=== <translate>Description</translate> ===
=== Description ===
<translate>Returns the current environment in use by the function. f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling getfenv. If the given function is not a Lua function, or if f is 0, getfenv returns the global environment. The default for f is 1.</translate>
Returns the current environment in use by the function.
<source lang="lua">
<syntaxhighlight lang="lua">
(table) = getfenv(f)
(table) = getfenv(f)
</source>
</syntaxhighlight>


=== <translate>Parameters</translate> ===
''f'' can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling getfenv. If the given function is not a Lua function, or if f is 0, getfenv returns the global environment. The default for f is 1.
'''f''': (varies) <translate>function or number(call stack level)</translate> '''optional'''<br/>


=== <translate>Return values</translate> ===
=== Parameters ===
'''<translate>Returns</translate>''' (table) <translate>environment with all the defined values in environment scope</translate><br/>
'''f''': (varies) function or number(call stack level) '''optional'''<br/>
 
=== Return values ===
'''Returns''' (table) environment with all the defined values in environment scope<br/>
 
=== See also ===
'''https://luau.org/library#global-functions'''<br/>


{{(global)}}
{{(global)}}

Latest revision as of 10:19, 21 July 2025

Available since: Gideros 2011.6
Class: (global)

Description

Returns the current environment in use by the function.

(table) = getfenv(f)

f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling getfenv. If the given function is not a Lua function, or if f is 0, getfenv returns the global environment. The default for f is 1.

Parameters

f: (varies) function or number(call stack level) optional

Return values

Returns (table) environment with all the defined values in environment scope

See also

https://luau.org/library#global-functions