Yuari
Documentation
Docs/Filter/ArgumentFilter.new

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

ParameterTypeDescription
argument_indexnumberOne-based argument position inspected by the filter.
argumentanyValue that the selected argument must equal.

Returns

TypeDescription
ArgumentFilterA 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.