AcediaDocumentation

debug.setupvalue

Writes a Lua function's captured value.

Unlike setconstant, this can change the value type. Other closures sharing the same capture can observe the write.

debug.setupvalue(subject: function | number, index: number, value: any): ()

Parameters

ParameterTypeDescription
subjectfunction | numberLua function or reachable stack level. C functions are rejected by prototype readers.
indexnumberOne-based upvalue index.
valueanyReplacement value.

Errors: An out-of-range index raises an error.

Aliases: setupvalue.

On this page