FilterBase
Construct and combine the current module function filters.
Filters are module-created tables with validated properties and a protected FilterBase metatable. FilterBase itself is an empty namespace with no public constructor. Build a concrete filter using one of the .new functions below, combine it, then pass it to hookfunction/hookmetamethod or getfilter.
Argument indices are positive and 1-based; an implicit method receiver counts as argument 1. Out-of-range indexed arguments do not match. Evaluation short-circuits All/Any lists, rejects cycles, and raises an error beyond 64 levels or 4096 visited nodes.
AllFilter.new
AllFilter.new(filters: {FilterBase}? = {}): FilterBaseMatches only when every child filter matches. An empty list matches.
Parameters
filters{FilterBase}?- Optional.Sequential child filter list. Default
{}.
Returns
FilterBaseConcrete filter table with properties: Filters: {FilterBase}.
Example
AnyFilter.new
AnyFilter.new(filters: {FilterBase}? = {}): FilterBaseMatches when any child filter matches. An empty list does not match.
Parameters
filters{FilterBase}?- Optional.Sequential child filter list. Default
{}.
Returns
FilterBaseConcrete filter table with properties: Filters: {FilterBase}.
Example
NotFilter.new
NotFilter.new(target: FilterBase): FilterBaseNegates a child filter. An invalid nested filter does not become a successful match.
Parameters
targetFilterBase- Child filter to negate.
Returns
FilterBaseConcrete filter table with properties: Target: FilterBase.
Example
TypeFilter.new
TypeFilter.new(index: number, argumentType: string): FilterBaseCompares the base Luau type name of an argument, not Roblox typeof. For example an Instance is userdata here.
Parameters
indexnumber- Positive argument index.
argumentTypestring- Base type name, such as string, number, table or userdata.
Returns
FilterBaseConcrete filter table with properties: ArgumentIndex: number; ArgumentType: string.
Example
NamecallFilter.new
NamecallFilter.new(method: string): FilterBaseCompares the current thread namecall method using an exact case-sensitive byte comparison.
Parameters
methodstring- Namecall method name.
Returns
FilterBaseConcrete filter table with properties: NamecallMethod: string.
Example
InstanceTypeFilter.new
InstanceTypeFilter.new(index: number, className: string): FilterBaseMatches an Instance argument using the native IsA class relation, so inherited classes match too.
Parameters
indexnumber- Positive argument index.
classNamestring- Native class name, such as BasePart.
Returns
FilterBaseConcrete filter table with properties: ArgumentIndex: number; InstanceType: string.
Example
ArgumentFilter.new
ArgumentFilter.new(index: number, argument: any): FilterBaseMatches one argument by raw equality. Tables/functions match by identity. StripNull defaults to false; when enabled for two strings, comparison truncates each at its first NUL byte.
Parameters
indexnumber- Positive argument index.
argumentany- Value to match, including nil.
Returns
FilterBaseConcrete filter table with properties: ArgumentIndex: number; Argument: any; StripNull: boolean = false.
Example
UserdataTypeFilter.new
UserdataTypeFilter.new(index: number, exemplar: userdata): FilterBaseMatches userdata with the same native tag and metatable as an exemplar. The UserdataType property is write-only and stores the exemplar userdata, not a type-name string.
Parameters
indexnumber- Positive argument index.
exemplaruserdata- Value representing the desired userdata kind.
Returns
FilterBaseConcrete filter table with properties: ArgumentIndex: number; UserdataType: userdata (write-only).
Example
ArgCountFilter.new
ArgCountFilter.new(count: number): FilterBaseMatches exactly the number of arguments delivered to the filtered call, including nil arguments and an explicit receiver.
Parameters
countnumber- Nonnegative exact argument count.
Returns
FilterBaseConcrete filter table with properties: ArgumentCount: number.
Example
CallerFilter.new
CallerFilter.new(invert: boolean): FilterBaseMatches module-marked calling threads when invert is false, or unmarked calling threads when invert is true.
Parameters
invertboolean- Whether to invert the module thread-mark test.
Returns
FilterBaseConcrete filter table with properties: Invert: boolean.
Example
getfilter
getfilter(filter: FilterBase, fallback: function, matched: function): functionCreates a yield-capable dispatcher. Each call evaluates the filter against its original argument list, then calls matched when it succeeds or fallback when it does not. Arguments and all return values are forwarded.
Parameters
filterFilterBase- Concrete module filter object.
fallbackfunction- Callback for a nonmatching or invalid filter result.
matchedfunction- Callback for a successful match.
Returns
functionC dispatcher retaining the filter and both callbacks.
Example
Written for Lynx 0.0.0
Something unclear? Tell us on Discord