debug. setconstant Synchronous
setconstant
Replace one literal slot in a Luau prototype. This changes code that uses the slot, so save the old value if the edit should be temporary.
Luau
debug.setconstant(target: DebugTarget, index: number, value: any) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
target | DebugTarget | A Luau function, visible stack level, or ProtoProxy. Indexes in these APIs start at 1. |
index | number | One-based constant slot to replace. |
value | any | Replacement value. |
Argument fields
Luau
DebugTarget = Function | number | ProtoProxyReturns
()No value.
Example
Luau
local function label() return "before" end
local old = debug.getconstant(label, 1)
debug.setconstant(label, 1, "after")
print(label()) -- after
debug.setconstant(label, 1, old)