Revision Difference
debug.setfenv#513382
<function name="setfenv" parent="debug" type="libraryfunc">⤶
<description>Sets the environment of the passed object.</description>⤶
<realm>Shared and Menu</realm>⤶
<args>⤶
<arg name="object" type="table">Object to set environment of</arg>⤶
<arg name="env" type="table">Environment to set</arg>⤶
</args>⤶
<rets>⤶
<ret name="" type="table">The object</ret>⤶
</rets>⤶
</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⤶
⤶
debug.setfenv( Display , newenvironment )⤶
⤶
Display()⤶
</code>⤶
<outputfixedwidth>Fixed width</outputfixedwidth>⤶
<output>yay</output>⤶
⤶
</example>