oth.is_hook_thread

Returns true if the current thread is a hook thread.

Syntax

oth.is_hook_thread() -> boolean

Returns

TypeDescription
booleanTrue 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 5

Conditional 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 true only when executing within a hook created by oth.hook
  • Returns false on the main thread or in other contexts
  • Useful for implementing hook-specific behavior