Debug

getstack

Reads stack values from a stack level, or one stack slot when an index is provided.

Syntax

getstack(level: number | integer, index?: number | integer): table
Aliases debug.getstack

Arguments

NameTypeDescription
levelnumber | integerOne-based stack level to inspect or update.
index?number | integerOne-based index inside constants, protos, upvalues, or stack slots.

Returns

NameTypeDescription
stacktableStack table or selected stack value.

Description

Reads stack values from a stack level, or one stack slot when an index is provided.

Call it with 2 parameter(s): level, index. The argument table explains which values are required and which ones only refine the behavior.

It returns stack (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = getstack(1, 1)
print(result)