oth.hook
Installs a hook whose body runs in a separate task while the caller waits for its results.
Syntax
oth.hook(target: function, hook: function) -> function
Parameters
| Parameter | Type | Description |
|---|---|---|
target | function | Function to replace. |
hook | function | Callback executed in the separate task. |
Returns
| Type | Description |
|---|---|
function | Original callable returned by the hook installation. |
Description
The callback receives the target’s arguments. Returned values and errors are delivered to the waiting caller. The supported wait is bounded; a hook must not leave its caller waiting indefinitely. Use oth.unhook to restore the target. This is separate from an ordinary hookfunction call.
Example
local function target(x) return x + 1 end
local original = oth.hook(target, function(x) return x * 2 end)
print(target(3))
oth.unhook(target)
Notes
- This compatibility path requires a working game task scheduler and has a bounded wait.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
