ReferenceClosures

restorefunction

Undoes hookfunction, giving a hooked function its original behavior back.

Syntax

restorefunction(func: function) -> ()

Also available as

restoreclosurerestorefuncrestore_function

Parameters

ParameterTypeDescription
funcfunctionA function previously hooked with hookfunction.

Description

After the call every reference to func runs the original implementation again. Restoring always returns to the first implementation, even when the function was hooked several times. Copies you saved earlier with clonefunction or from hookfunction's return value keep working.

Example

local function value()
    return 1
end

hookfunction(value, function() return 2 end)
print(value())

restorefunction(value)
print(value())

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.