debug.getconstant
Reads one constant from a Lua function or a visible caller frame.
Syntax
debug.getconstant(target: function | number, index: number) -> any
Also available as
getconstantget_constant
Parameters
| Parameter | Type | Description |
|---|---|---|
target | function or number | Lua function, or caller level starting at 1. |
index | number | One-based constant index. |
Returns
| Type | Description |
|---|---|
any | The constant value; an existing nil constant returns nil. |
Description
Constants include literal strings, numbers and booleans stored with compiled code. They are not local variables or upvalues. Indices start at 1; use debug.getconstants to inspect the table before selecting an index. C functions and indices outside the constant table raise errors.
Example
local function sample() return "sample" end
for index, value in debug.getconstants(sample) do
print(index, debug.getconstant(sample, index))
end
These are Game executor contracts. Check build requirements and session lifetimes before using them.
