debug.getproto
Selects the nested function prototypes declared inside a Lua function.
Syntax
debug.getproto(target: function | number, index: number, activated: boolean?) -> function | {function}
Also available as
getprotoget_proto
Parameters
| Parameter | Type | Description |
|---|---|---|
target | function or number | Lua function or visible caller level. |
index | number | One-based nested prototype index. |
activated | boolean? | Return retained live closures; defaults to false. |
Returns
| Type | Description |
|---|---|
function or {function} | Inactive functions, or matching live closures when activated is true. |
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. With activated true, the result is a table of retained live closures matching that prototype. Without it, the result is an inactive function value. Do not expect an inactive value to reproduce a live closure’s captured variables.
Example
local function outer()
local function inner() return 7 end
return inner
end
local prototype = debug.getproto(outer, 1)
print(type(prototype))
These are Game executor contracts. Check build requirements and session lifetimes before using them.
