Debug

setconstant

Replaces a constant in a function or prototype by one-based index.

Syntax

setconstant(target: function | integer, index: number | integer, value: any)
Aliases debug.setconstant

Arguments

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

Description

Replaces a constant in a function or prototype by one-based index.

Call it with 3 parameter(s): target, 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.

setconstant(1, 1, nil)