debug.getprotos
Gets all protos (nested functions) from a function.
Syntax
debug.getprotos(func: function | number | ProtoProxy) -> {ProtoProxy}Parameters
| Parameter | Type | Description |
|---|---|---|
func | function, stack level, or ProtoProxy | The prototype to inspect |
Returns
| Type | Description |
|---|---|
table | An array of ProtoProxy values for all nested prototypes |
Description
debug.getprotos returns ProtoProxy values for nested functions. These values can be used with compatible debug functions, but cannot be called directly.
Example
local function container()
local function a() return 1 end
local function b() return 2 end
local function c() return 3 end
return a() + b() + c()
end
local protos = debug.getprotos(container)
print(#protos) -- 3
for i, proto in ipairs(protos) do
print(i, typeof(proto), #debug.getconstants(proto))
endUse Cases
- Script analysis: Find all functions defined within a script
- Hooking: Locate specific nested functions to hook
- Debugging: Inspect the structure of complex functions
Related Functions
debug.getproto- Get a single proto by index