debug.getlocal

From GMod Wiki

Jump to: navigation, search
Stub.pngThis article is a stub.
You can help the GMod Wiki by expanding it.


Function
Syntax debug.getlocal( Integer level, Integer local )
Where is this used?
Description:
This function returns the name and the value of the local variable with index local of the function at level level of the stack. (The first parameter or local variable has index 1, and so on, until the last active local variable.) The function returns nil if there is no local variable with the given index, and raises an error when called with a level out of range. (You can call debug.getinfo to check whether the level is valid.)
Returns: String Name, Var Value
Part of Library: Debug
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Debug.getlocal]Debug.getlocal [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionPrints in console.
Used onNewerShared.png
Code
local TotalCakes = 12;
local Name, Value = debug.getlocal( 1 , TotalCakes );
print( Name, Value );
OutputTotalCakes 12
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox