Difference between revisions of "Setfenv"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === Sets the environment to be used by the given function. f can be a Lua function or a number that specif...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
'''Class:''' [[(global)]]<br/>
 +
 
=== Description ===
 
=== Description ===
Sets the environment to be used by the given function. 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.  
+
Sets the environment to be used by the given function.
 +
<syntaxhighlight lang="lua">
 +
(varies) = setfenv(f,table)
 +
</syntaxhighlight>
 +
 
 +
''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)<br/>
 +
'''table''': (table) environment table to set<br/>
  
As a special case, when f is 0 setfenv changes the environment of the running thread. In this case, setfenv returns no values.
+
=== Return values ===
<source lang="lua">
 
(varies), = setfenv(ftable,)
 
</source>
 
'''f:''' (varies) function or number(call stack level) ''''''<br/>
 
'''table:''' (table) environment table to set ''''''<br/>
 
 
'''Returns''' (varies) returns provided function or nil<br/>
 
'''Returns''' (varies) returns provided function or nil<br/>
 +
 +
{{(global)}}

Latest revision as of 14:32, 13 July 2023

Available since: Gideros 2011.6
Class: (global)

Description

Sets the environment to be used by the given function.

(varies) = setfenv(f,table)

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