debug.getproto
C closures are not supported
This function will throw an error if called on a C closure, such as print, since C closures do not contain function prototypes.
Inactive protos
Protos retrieved without the activated should not be callable; this leads to vulnerabilities.
The usage of inactive protos is to retrieve information off of them.
debug.getproto returns a specific function prototype from a Luau function by index. Optionally, it can search for active functions of the proto, if the activated parameter is set to true.
These are internal function definitions (e.g. nested functions) that exist as part of the compiled bytecode, even if they aren't assigned or called.
function debug.getproto(func: (...any) -> (...any) | number, index: number, activated: boolean?): (...any) -> (...any) | { (...any) -> (...any) }
Parameters
| Parameter | Description |
|---|---|
func |
The Luau function (or stack level) to extract a proto from. |
index |
The index of the prototype to return. |
activated? |
If true, returns a table of currently active functions based on the proto. |
Examples
Example 1
| Retrieving nested prototypes | |
|---|---|
Example 2
| Retrieving an active function from a proto | |
|---|---|