Debug

setupvalue

Replaces an upvalue in a function by one-based index.

Syntax

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

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 an upvalue in a function 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.

setupvalue(1, 1, nil)