Revision Difference
Global.setfenv#528439
<function name="setfenv" parent="Global" type="libraryfunc">
<description>Sets the enviroment for a function or a stack level, if a function is passed, the return value will be the function, otherwise nil.</description>
<realm>Shared and Menu</realm>
<args>
<arg name="location" type="function">The function to set the enviroment for or a number representing stack level.</arg>
<arg name="enviroment" type="table">Table to be used as enviroment.</arg>
</args>
</function>
<example>
<description>Create a new environment and setfenv Display inside it</description>
<code>
local newenvironment = {}
function newenvironment.log( msg )
print( msg )
end
local function Display()
log( "yay" )
end
setfenv( Display , newenvironment )
Display()
</code>
<outputfixedwidth>Fixed width</outputfixedwidth>⤶
<output>yay</output>⤶
<output>⤶
```⤶
yay⤶
```⤶
</output>⤶
</example>