ArgumentFilter.new
ArgumentFilter.new creates a filter that compares one argument with a stored value.
Syntax
ArgumentFilter.new(argument_index: number, argument: any) -> ArgumentFilter
Parameters
| Parameter | Type | Description |
|---|---|---|
argument_index | number | One-based argument position inspected by the filter. |
argument | any | Value that the selected argument must equal. |
Returns
| Type | Description |
|---|---|
ArgumentFilter | A filter that matches when the selected argument equals the stored value. |
Description
ArgumentFilter.new stores a one-based argument position and a value. At evaluation time the argument at that position is compared with the stored value; missing positions never match.
Comparison is raw, so primitives compare by value while tables, functions and userdata compare by identity. This avoids invoking user metamethods while a hook is running.
Example
local wantsHello = ArgumentFilter.new(1, "hello")
print(wantsHello) -- ArgumentFilter
Notes
- hookfunction accepts a filter as an optional third argument; getfilter accepts one directly.
- The index must be positive.
- Nil can be stored, but a missing argument does not match nil.