Scaleform Studio Lua API Reference: debug namespace reference

debug namespace reference

Description

Used for debugging and all functions are provided inside the debug table.

Functions

Parameters
This function does not accept any parameters.
Returns
This function does not return any values.
Parameters

obj :

userdata

The object whose environment is returned.

Returns

string

A string containing the environment of the object.

Parameters

thread :

string

The thread whose hook settings are returned.

Returns

any*

The current hook settings returned as three values - hook function, mask and count.

The * notation indicates that there may be zero or more instances of the specified type.
Parameters

thread :

string?

The current thread.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

f :

any*

The function whose info is retrieved.

The * notation indicates that there may be zero or more instances of the specified type.

what :

string*

Indicates what values to return.

The * notation indicates that there may be zero or more instances of the specified type.
Returns

table

Returns a table with the function information.

The function can be given directly or as a number representing the stack level, where 0 is debug.getinfo itself, 1 is the function that called debug.getinfo, 2 is the function that called that, and so on. Returns nil if the function number is larger than the number of functions on the stack.

Parameters

level :

integer

The level of the stack.

local :

integer

The index of the function.

Returns

any*

The name and value of the local variable.

The * notation indicates that there may be zero or more instances of the specified type.

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.

Parameters

obj :

userdata

The object whose metatable is returned.

Returns

table

The metatable of the object.

Parameters
This function does not accept any parameters.
Returns

table

The registry table.

This is a pre-defined table that can be used by any C code to store whatever Lua value it needs to store.

Parameters

func :

fun(any*:any*)

The function.

The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..

up :

integer

The index of the function.

Returns

any*

The name and the value of the upvalue.

The * notation indicates that there may be zero or more instances of the specified type.

The function returns nil if there is no upvalue with the given index.

Parameters

obj :

userdata

The object.

tble :

table

The table to which the environment value is stored.

Returns

userdata

Returns the object whose environment is set.

Returns the object, obj.

Parameters

thread :

string

A string describing the event that has triggered its call: "call", "return" (or "tail return", when simulating a return from a tail call), "line", and "count".

hook :

fun(any:any)

The function set as hook.

The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..

mask :

string

A string, and can have the following meaning: - "c": the hook is called every time Lua calls a function. - "r": the hook is called every time Lua returns from a function. - "l": the hook is called every time Lua enters a new line of code.

count :

integer

If non-zero, the hook is called after every count instructions.

Returns
This function does not return any values.

The string mask and the number count describe when the hook will be called. When called without arguments, debug.sethook turns off the hook. When the hook is called, its first parameter is a string describing the event that has triggered its call. For line events, the hook also gets the new line number as its second parameter. Inside a hook, you can call getinfo with level 2 to get information about the running function (level 0 is the getinfo function, and level 1 is the hook function). In case the event is "tail return", Lua is only simulating the return, and a call to getinfo will return invalid data.

Parameters

level :

integer

The level on the stack.

local :

any

The index of the function.

value :

any

The value of the variable.

Returns
This function does not return any values.

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.

Parameters

obj :

userdata

The object.

tble :

table

The table to which the metatable is stored.

Returns
This function does not return any values.
Parameters

func :

fun(any*:any*)

The function whose upvalue is set.

The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..

up :

integer

The index of the function.

value :

any

The value assigned as the upvalue.

Returns

string

The name of the upvalue.

The function returns nil if there is no upvalue with the given index. Otherwise, it returns the name of the upvalue.

Parameters

message :

string?

An message string which is appended at the beginning of the traceback.

The ? notation indicates that this type is optional: there may be zero or one instances of it.

level :

integer?

An number tells at which level to start the traceback (default is 1, the function calling traceback).

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns

string

Contains the traceback of the call stack.

 debug.debug ()
Enters an interactive mode with the user, running each string that the user enters.
 debug.getfenv (obj) : string
Returns the environment of the object.
 obj : userdata
The object whose environment is returned.
 string
A string containing the environment of the object.
A raw memory buffer that is allocated and maintained in the Lua environment.A string of characters.  debug.gethook (thread) : any*
Returns the current hook settings of the thread.
 thread : string
The thread whose hook settings are returned.
 any*
The current hook settings returned as three values - hook function, mask and count.
The * notation indicates that there may be zero or more instances of the specified type.
This value may be an instance of any type.  debug.getinfo (thread, f, what) : table
Returns a table with information about a function.
 thread : string?
The current thread.
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 f : any*
The function whose info is retrieved.
The * notation indicates that there may be zero or more instances of the specified type.
 what : string*
Indicates what values to return.
The * notation indicates that there may be zero or more instances of the specified type.
 table
Returns a table with the function information.
A Lua table consisting of paired keys and values.  debug.getlocal (level, local) : any*
Returns the name and value of the local variable with the index local of the function at level level on the stack.
 level : integer
The level of the stack.
 local : integer
The index of the function.
 any*
The name and value of the local variable.
The * notation indicates that there may be zero or more instances of the specified type.
A strictly integral numeric value, with no decimal component.  debug.getmetatable (obj) : table
Returns the metatable of the given object or nil if it does not have a metatable.
 obj : userdata
The object whose metatable is returned.
 table
The metatable of the object.
 debug.getregistry () : table
Returns the registry table.
 table
The registry table.
 debug.getupvalue (func, up) : any*
Returns the name and the value of the upvalue with index up of the function func.
 func : fun(any*:any*)
The function.
The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..
 up : integer
The index of the function.
 any*
The name and the value of the upvalue.
The * notation indicates that there may be zero or more instances of the specified type.
 debug.setfenv (obj, tble) : userdata
Sets the environment of the given object to the given table.
 obj : userdata
The object.
 tble : table
The table to which the environment value is stored.
 userdata
Returns the object whose environment is set.
 debug.sethook (thread, hook, mask, count)
Sets the given function as a hook.
 thread : string
A string describing the event that has triggered its call: "call", "return" (or "tail return", when simulating a return from a tail call), "line", and "count".
 hook : fun(any:any)
The function set as hook.
The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..
 mask : string
A string, and can have the following meaning: - "c": the hook is called every time Lua calls a function. [more...]
 count : integer
If non-zero, the hook is called after every count instructions.
 debug.setlocal (level, local, value)
Sets the value of the local variable with the index 'local' of the function at 'level' on the stack.
 level : integer
The level on the stack.
 local : any
The index of the function.
 value : any
The value of the variable.
 debug.setmetatable (obj, tble)
Sets the metatable for the given object to the given table.
 obj : userdata
The object.
 tble : table
The table to which the metatable is stored.
 debug.setupvalue (func, up, value) : string
Sets an upvalue for the function - assigns the value value to the upvalue with index up of the function func.
 func : fun(any*:any*)
The function whose upvalue is set.
The fun(...) notation indicates that this is a function that accepts parameters of the types shown to the left of the colon :, and that returns the types shown to the right of the colon..
 up : integer
The index of the function.
 value : any
The value assigned as the upvalue.
 string
The name of the upvalue.
 debug.traceback (message, level) : string
Returns a string with a traceback of the call stack.
 message : string?
An message string which is appended at the beginning of the traceback.
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 level : integer?
An number tells at which level to start the traceback (default is 1, the function calling traceback).
The ? notation indicates that this type is optional: there may be zero or one instances of it.
 string
Contains the traceback of the call stack.
Indicates a table.
This documentation uses the term table to mean an anonymous, temporary Lua table that contains named data values. You typically use these tables to pass data or settings to a function, or to hold data returned by a function.
Indicates an object.
This documentation uses the term object to mean a named Lua table or userdata value that maintains a state. Some object types may have multiple instances existing at the same time, each with its own state; these objects typically have creation functions or accessors that you must call in order to get an instance. Some object types have only one instance, which you always access through the object's name.
Indicates a named variable within a namespace, object or table; or an element within an enumeration.Indicates a code sample.Indicates an enumeration.
This documentation uses the term enumeration to mean a named Lua table that contains only a set of constant values. These values typically identify a predefined set of options for some setting or behavior. You might pass an enumeration value to a function, or test the value returned by a function against the items in the enumeration to see which option is currently set.
Indicates a named variable within a namespace or object that has a pre-set constant value.Indicates a category: a semantic grouping of related API elements.Indicates a namespace.
This documentation uses the term namespace to mean a named Lua table that exists in only one single instance, intended as a container for an interface of related objects, functions and data variables.
Indicates an output value returned by a function.Indicates a named function within a namespace or object.Indicates an input parameter for a function.