Difference between revisions of "Setfenv"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Sets the environment to be used by the given function. | Sets the environment to be used by the given function. | ||
− | < | + | <syntaxhighlight lang="lua"> |
(varies) = setfenv(f,table) | (varies) = setfenv(f,table) | ||
</source> | </source> |
Revision as of 14:30, 13 July 2023
Available since: Gideros 2011.6
Class: (global)
Description
Sets the environment to be used by the given function. <syntaxhighlight lang="lua"> (varies) = setfenv(f,table) </source>
f can be a Lua function or a number that specifies the function at that stack level: Level 1 is the function calling setfenv. setfenv returns the given function.
As a special case, when f is 0 setfenv changes the environment of the running thread. In this case, setfenv returns no values.
Parameters
f: (varies) function or number(call stack level)
table: (table) environment table to set
Return values
Returns (varies) returns provided function or nil