debug.setupvalue

From GMod Wiki

Revision as of 21:19, 1 February 2011 by Donkie (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax debug.setupvalue( Function function , Integer up , Var value )
Where is this used?
Description:
This function assigns the value of value to the upvalue with index up of the function. The function returns nil if there is no upvalue with the given index.
Otherwise, it returns the name of the upvalue.
Returns: String name of the upvalue.
Part of Library: Debug
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Debug.setupvalue]Debug.setupvalue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionShows the usage of this function
Used onNewerShared.png
Code
 
-- (file1.lua)
local testvar = "test"
function stuff()
	print(test)
end
 
-- (file2.lua)
stuff() -- Call the function (prints test)
print(debug.setupvalue(stuff, 1, "pie")) // set "testvar" in the other file to "pie", prints testvar as that is the variable name
stuff() -- Call the function (prints pie)
 
Outputtest, testvar, pie


Additional Notes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox