ReferenceDebug

debug.getprotos

Lists the nested function prototypes declared inside a Lua function.

Syntax

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

Also available as

getprotosget_protos

Parameters

ParameterTypeDescription
targetfunction or numberLua function or visible caller level.

Returns

TypeDescription
{function}Inactive functions for nested prototypes.

Description

A prototype describes a nested function’s code; it is not necessarily an existing closure with captured state. Apex returns inactive function values for inspection. Use debug.getproto with activated set to true to request retained live closures for one prototype.

Example

local function outer()
    local function inner() return 7 end
    return inner
end
print(#debug.getprotos(outer))

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