ReferenceDebug

debug.getupvalues

Returns the captured variables of a Lua closure.

Syntax

debug.getupvalues(target: function | number) -> {any}

Also available as

getupvaluesget_upvalues

Parameters

ParameterTypeDescription
targetfunction or numberLua closure or visible caller level.

Returns

TypeDescription
tableUpvalues keyed by their index.

Description

Numeric keys correspond to upvalue indices, starting at 1. A nil captured value can leave a hole. This does not expose every local variable in the enclosing function; only values actually captured by the selected closure are upvalues.

Example

local captured = "hello"
local function sample() return captured end
for index, value in debug.getupvalues(sample) do
    print(index, value)
end

These are Game executor contracts. Check build requirements and session lifetimes before using them.