oth.is_hook_thread
Returns true if the current thread is a hook thread.
Syntax
oth.is_hook_thread() -> booleanReturns
| Type | Description |
|---|---|
boolean | True if running in a hook thread, false otherwise |
Description
oth.is_hook_thread checks whether the current code is executing within a hook thread created by oth.hook. This allows you to detect hook context and behave differently.
Example
local originalAbs
originalAbs = oth.hook(math.abs, function(value)
if oth.is_hook_thread() then
print("Hook thread detected")
end
return originalAbs(value)
end)
print(math.abs(-5)) -- Hook thread detected, then 5Conditional Behavior
local originalAbs
originalAbs = oth.hook(math.abs, function(value)
if oth.is_hook_thread() then
-- Running in hook thread
print("Hook context detected")
-- Do hook-specific logic
end
return originalAbs(value)
end)Notes
- Returns
trueonly when executing within a hook created byoth.hook - Returns
falseon the main thread or in other contexts - Useful for implementing hook-specific behavior
Related Functions
oth.hook- Create a hookget_original_thread- Get the original thread