restoreproto
Restore a proto hooked with hookproto.
Syntax
restoreproto(proto: ProtoProxy) -> ()Parameters
| Parameter | Type | Description |
|---|---|---|
proto | ProtoProxy | Hooked proto to restore |
Returns
This function does not return a value.
Description
restoreproto removes the active hook created with hookproto.
Existing and future closures that use the proto return to their original behavior.
If the proto was hooked more than once, restoreproto returns it to its original state. It does not restore the previous hook.
Calling restoreproto on a proto that is not hooked raises an error.
Example
local function makeValue()
local function getValue()
return "original"
end
return getValue
end
local getValue = makeValue()
local proto = debug.getproto(makeValue, 1)
hookproto(proto, function()
return "replacement"
end)
print(getValue()) -- replacement
print(isprotohooked(proto)) -- true
restoreproto(proto)
print(getValue()) -- original
print(isprotohooked(proto)) -- falseRelated Functions
hookproto- Hook a protoisprotohooked- Check if a proto is hookedProtoProxy- Learn about proto proxies