Yuari
Documentation
Docs/Filter/CallerFilter.new

CallerFilter.new

CallerFilter.new creates a filter that checks whether the caller is an executor closure.

Syntax

CallerFilter.new(invert: boolean) -> CallerFilter

Parameters

ParameterTypeDescription
invertbooleanWhen true, matches game callers instead of executor callers.

Returns

TypeDescription
CallerFilterA filter that matches based on whether the caller is an executor closure.

Description

CallerFilter.new inspects the call stack of the active Lua state. C dispatch frames, such as a namecall implementation, are skipped so the nearest Lua caller decides the result.

With invert set to false the filter matches calls made by executor closures. With invert set to true it matches calls that originate from game code, which is useful for letting the original implementation handle engine traffic while a script intercepts its own calls.

Example

local fromExecutor = CallerFilter.new(false)
local fromGame = CallerFilter.new(true)
print(fromExecutor, fromGame) -- CallerFilter CallerFilter

Notes

  • hookfunction accepts a filter as an optional third argument; getfilter accepts one directly.
  • Pass true to reverse the check.
  • The check reads the current stack and does not depend on the hook target.