Debug

setstack

Replaces a stack slot value at the selected stack level.

Syntax

setstack(level: number | integer, index: number | integer, value: any)
Aliases debug.setstack

Arguments

NameTypeDescription
levelnumber | integerOne-based stack level to inspect or update.
indexnumber | integerOne-based index inside constants, protos, upvalues, or stack slots.
valueanyNew value to write.

Description

Replaces a stack slot value at the selected stack level.

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

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Example call with placeholder values.

setstack(1, 1, nil)