getcallstack
Also available as debug.getcallstack get_callstack
Returns the current call stack as a list of entries. Each entry has the function, and for Lua functions the line being executed.
The debug library and its executor additions.
Also available as debug.getcallstack get_callstack
Returns the current call stack as a list of entries. Each entry has the function, and for Lua functions the line being executed.
Also available as debug.getconstant get_constant
Returns one constant from a function's compiled code, by index. Raises an error if the index is out of range.
function debug.getconstant(func: (...any) -> (...any) | number, index: number): number | string | boolean | nil
Also available as debug.getconstants get_constants
Returns all the constants a function's compiled code uses: numbers, strings and booleans.
function debug.getconstants(func: (...any) -> (...any) | number): { number | string | boolean | nil }
Also available as debug.getinfo get_info
Returns information about a function or stack level: its source, name, line numbers, parameter count and so on.
Also available as debug.getproto get_proto
Returns one of the functions defined inside a function, by index. With the active flag it returns the live functions that exist right now rather than fresh copies.
function debug.getproto(func: (...any) -> (...any) | number, index: number, activated: boolean?): (...any) -> (...any) | { (...any) -> (...any) }
Also available as debug.getprotos get_protos
Returns every function defined inside a function.
function debug.getprotos(func: (...any) -> (...any) | number): { (...any) -> (...any) }
Also available as debug.getstack get_stack
Reads a value from the stack of a running function at the given level and index. With no index it returns the whole level as a table.
function debug.getstack(level: number, index: number?): any | { any }
Also available as debug.getupvalue get_upvalue
Returns one of a function's upvalues, the outer variables it captured, by index.
function debug.getupvalue(func: (...any) -> (...any) | number, index: number): any
Also available as debug.getupvalues get_upvalues
Returns all of a function's upvalues as a table.
function debug.getupvalues(func: (...any) -> (...any) | number): { any }
Also available as debug.setconstant set_constant
Replaces one constant in a function's compiled code. The change affects every later call.
function debug.setconstant(func: (...any) -> (...any) | number, index: number, value: number | string | boolean | nil): ()
Also available as debug.setstack set_stack
Writes a value into a stack slot of a running function.
function debug.setstack(level: number, index: number, value: any): ()
Also available as debug.setupvalue set_upvalue
Changes one of a function's upvalues by index. Use it to alter variables a function captured.
function debug.setupvalue(func: (...any) -> (...any) | number, index: number, value: any): ()