debug/setupvalue

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Another correction)
m (Made the page cleaner)
Line 2: Line 2:
 
|Name=setupvalue
 
|Name=setupvalue
 
|Parent=debug
 
|Parent=debug
|Description=Sets the variable indexed by 'up' from function 'f' to 'newValue'.
+
|Description=Sets the variable indexed from func
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
Line 8: Line 8:
 
{{Arg
 
{{Arg
 
|type=function
 
|type=function
|name=f
+
|name=func
|desc=The function to index the upvalue from.
+
|desc=The function to index the upvalue from
 
}}
 
}}
 
{{Arg
 
{{Arg
 
|type=number
 
|type=number
|name=up
+
|name=index
|desc=The index from the function 'f'.
+
|desc=The index from func
 
}}
 
}}
 
{{Arg
 
{{Arg
 
|type=any
 
|type=any
|name=newValue
+
|name=val
 
|desc=The value to set the upvalue to.
 
|desc=The value to set the upvalue to.
 
|default=nil
 
|default=nil

Revision as of 17:22, 21 January 2015

 debug.setupvalue( )

Contents

Description

Sets the variable indexed from func

Arguments

function func

The function to index the upvalue from

Arguments

number index

The index from func

Arguments

any val=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