hookfunction
Replaces a function's behavior and returns a callable copy of its previous behavior.
Retain the returned original to call the pre-hook implementation. Certain executor namecall wrapper targets are protected and return nil.
hookfunction(target: function, replacement: function): function?Parameters
| Parameter | Type | Description |
|---|---|---|
target | function | Function whose calls will be redirected. |
replacement | function | New implementation. |
Example
local function target(value) return value + 1 end
local original = hookfunction(target, function(value) return value + 10 end)
print(target(1), original(1))
restorefunction(target)Example output
11 2Aliases: replaceclosure, hookfunc.
