restoreproto

Restore a proto hooked with hookproto.

Syntax

restoreproto(proto: ProtoProxy) -> ()

Parameters

ParameterTypeDescription
protoProtoProxyHooked 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)) -- false