AnyFilter. new Synchronous
Match when at least one child filter matches. Use it to allow several independent cases without installing separate hooks.
Luau
AnyFilter.new(filters: {HookFilter}) -> HookFilterParameters
| Parameter | Type | Description |
|---|---|---|
filters | {HookFilter} | An array of HookFilter objects. Matching stops at the first matching child; an empty array matches no calls. |
Returns
HookFilterA HookFilter table to pass as the optional filter argument of hookfunction, hookmetamethod, or oth.hook. It does not run until a hooked call is evaluated.
Usage notes
A match calls the replacement. A miss continues through the preceding hook or original function. Omit the filter or pass nil to handle every call.
Compound filters short-circuit. A visited invalid or cyclic child fails the match, including inside NotFilter. Evaluation supports at most 64 nested levels and 256 children in one compound filter; exceeding a limit fails the match.
Example
Luau
local target = newcclosure(function(value) return value end)
local filter = AnyFilter.new({
ArgumentFilter.new(1, "start"),
ArgumentFilter.new(1, "stop"),
})
local previous
previous = hookfunction(target, function(value)
return "handled: " .. previous(value)
end, filter)
print(target("start")) -- handled: start
print(target("other")) -- other
restorefunction(target)