Syntax
hookfunction(target: function, replacement: function): functionAliases
hookfuncreplaceclosuredetourfunctiondetour_functionArguments
| Name | Type | Description |
|---|---|---|
target | function | Target function, table, stack level, or object being inspected or changed. |
replacement | function | Replacement value or function that should be installed. |
Returns
| Name | Type | Description |
|---|---|---|
original | function | Original function before it was replaced. |
Description
Replaces a target function with a replacement and returns the original function.
Call it with 2 parameter(s): target, replacement. The argument table explains which values are required and which ones only refine the behavior.
It returns original (function). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Example call with placeholder values.
local result = hookfunction(function() end, function() end)
print(result)