oth. unhook Synchronous
Remove one OTH hook layer from a target. Select a specific layer when several callbacks have been installed.
Luau
oth.unhook(target: Function, selector: Function?) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
target | Function | The C closure originally passed to oth.hook. |
selector | Function? | Optional returned callable or callback function identifying the layer. Omit it only when exactly one active layer remains. |
Returns
booleantrue when a layer was removed; false when no matching target or selector was found.
Usage notes
With multiple active layers, omitting the selector raises an error without changing the chain. A callback function selects its most recently installed active registration.
Removing the last layer restores the target. A call already in progress can finish using its saved callback context.
Example
Luau
local target = newcclosure(function(value) return value end)
local first = oth.hook(target, function(value) return value .. "!" end)
local second = oth.hook(target, function(value) return value .. "?" end)
print(oth.unhook(target, second)) -- true: remove second layer
print(oth.unhook(target, first)) -- true: restore target