Skip to content
Thread dispatchOverview

oth.replace_hook

Represents replacement of a dispatch callback.

Details#

Changes the Luau callback of an already oth-hooked target while keeping its saved original. An unhooked target or C-closure replacement raises an error. Use oth.unhook after the experiment.

Examples#

Example

Luau
local target = newcclosure(function() return 1 end)
oth.hook(target, function() return 2 end)
oth.replace_hook(target, function() return 3 end)
print(target()) -- 3
oth.unhook(target)