debug.setupvalue

From Garry's Mod
Revision as of 14:27, 21 January 2015 by Yupi2 (Talk | contribs)
Jump to: navigation, search
 debug.setupvalue( )

Contents

Description

Sets the variable indexed by 'up' from function 'f' to 'newValue'.

Arguments

function f

The function to index the upvalue from.

Arguments

number up

The index upwards from the function f.

Arguments

any newValue=nil

The value to set the upvalue to.

Returns

string

Returns nil if there is no upvalue with the given index, otherwise it returns the upvalue's name.

Examples

Example

An example demonstrating a function overwrite.

local function my_isfunction(f)
	return type(f) == "function" or f == "coolguy"	
end

print(debug.setupvalue(hook.Add, 1, my_isfunction))

Output:

isfunction
Personal tools
Navigation