Closures

isfunctionhooked

Returns whether the provided function currently has a hook record.

Syntax

isfunctionhooked(func: function): boolean

Arguments

NameTypeDescription
funcfunctionFunction to check. Passing a non-function raises a type error.

Returns

NameTypeDescription
hookedbooleantrue when the function is currently hooked; otherwise false.

Description

Returns whether the provided function currently has a hook record. The argument must be a function.

Call it with 1 parameter(s): func. The argument table explains which values are required and which ones only refine the behavior.

It returns hooked (boolean). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Check whether a function closure is tracked as a hook target.

local function target()
end

print(isfunctionhooked(target))