oth.unhook

Removes a hook created with oth.hook.

Syntax

oth.unhook(target: function) -> boolean

Parameters

ParameterTypeDescription
targetfunctionThe hooked function to remove

Returns

TypeDescription
booleanTrue if the hook was successfully removed

Description

oth.unhook removes a hook from a function that was created with oth.hook. The function is restored to its original behavior.

Example

-- Hook a function
local originalAbs
originalAbs = oth.hook(math.abs, function(value)
    return originalAbs(value) + 1
end)

-- Later, remove the hook
local success = oth.unhook(math.abs)
if success then
    print("Hook removed successfully")
end

Check Hook Status

local originalAbs
originalAbs = oth.hook(math.abs, function(value)
    return originalAbs(value)
end)

-- Remove hook
if oth.unhook(math.abs) then
    print("Hook removed")
else
    print("No hook to remove")
end

Notes

  • Only works on functions hooked with oth.hook
  • Returns false if the function wasn't hooked or hook removal failed
  • The original function reference from oth.hook remains valid after unhooking