debug.getstack
Reads or writes a stack level. Globals: getstack / setstack.
Syntax
debug.getstack(level?: number) -> any
Parameters
| Parameter | Type | Description |
|---|---|---|
level? | number | The level value used by the call. |
Returns
| Type | Description |
|---|---|
any | The value produced by the call. |
Description
debug.getstack is part of the Debug library. The debug library exposes the internals of the active Luau state, including protos, constants, upvalues and stack frames.
The call is read-only: it resolves the current value when invoked and does not change the underlying state.
The aliases debug.setstack(level, index, value) resolve to the same implementation.
Example
local stack = debug.getstack(1)
print(#stack)
debug.setstack(1, 1, "patched")
Notes
- Aliases:
debug.setstack(level, index, value). - Writing protos, constants or upvalues can corrupt a running function; test changes carefully.