debug.setfenv

From Garry's Mod
Jump to: navigation, search
 debug.setfenv( )

Contents

Description

Sets the environment of the passed object.

Arguments

table object

Object to set environment of

Arguments

table env

Environment to set

Returns

table

The object

Examples

Example

create a new environment and setfenv Display inside it

local newenvironment = {}

function newenvironment.log( msg )
	print( msg )
end

local function Display()
	log( "yay" )
end

debug.setfenv( Display , newenvironment )

Display()

Output:

yay
Personal tools
Navigation