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 originalPrint = oth.hook(print, function(...)
if oth.is_hook_thread() then
print("[HOOK THREAD]", ...)
else
print("[MAIN THREAD]", ...)
end
return originalPrint(...)
end)
print("Test") -- Output: [HOOK THREAD] TestConditional Behavior
local originalFunc = oth.hook(someCFunction, function(...)
if oth.is_hook_thread() then
-- Running in hook thread
print("Hook context detected")
-- Do hook-specific logic
end
return originalFunc(...)
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