ReferenceEnvironment

filtergc

Searches the garbage collector for functions or tables matching a set of conditions.

Syntax

filtergc(kind: "function" | "table", options: FilterOptions, returnOne: boolean?) -> any | {any}

Also available as

filter_gc

Parameters

ParameterTypeDescription
kindstring"function" or "table": which kind of value to search for.
optionsFilterOptionsThe conditions a value must meet. See the description for the fields.
returnOneboolean?When true, return the first match, or nil, instead of a list.

Returns

TypeDescription
any or {any}Every matching value, or the first match when returnOne is true.

Description

For functions, the options are Name (the function's debug name), Hash (its getfunctionhash value), Constants (values that must all appear among its constants), Upvalues (values that must all appear among its upvalues), UpvalueCount (an exact nonnegative integer count of captures) and IgnoreExecutor (skip functions from your own code; defaults to true).

For tables, the options are Keys (keys that must be present), Values (values that must be present), KeyValuePairs (a table of pairs that must all match) and Metatable (the table's metatable must be exactly this one).

A value matches only when every option you gave matches, so adding options narrows the search.

Example

local damage = filtergc("function", {
    Name = "CalculateDamage",
    Constants = { "Critical" },
}, true)

local configs = filtergc("table", {
    Keys = { "WalkSpeed", "JumpPower" },
})
print(damage, #configs)

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.