debug.setstack
Writes a live Lua frame’s stack slots.
Syntax
debug.setstack(level: number, index: number, value: any) -> ()
Also available as
setstackset_stack
Parameters
| Parameter | Type | Description |
|---|---|---|
level | number | Visible caller level, starting at 1. |
index | number | One-based slot. |
value | any | Replacement slot value. |
Description
Level 1 identifies the Lua caller; larger levels walk outward through visible frames. Slots are temporary VM values, not stable source-variable names. C frames and invalid indices raise errors. Use only a slot whose current meaning is known; writing an unrelated temporary changes subsequent execution.
Example
local function inspect()
local marker = "stack-example"
local slots = debug.getstack(1)
print(marker, type(slots))
end
inspect()
Notes
- Stack slot numbering can change when code is recompiled.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
