Environment APIs

Functions

getgenv

table getgenv()

Returns Synapse's global environment table.

getrenv

table getrenv()

Returns the game's global environment table.

getreg

table getreg()

Returns a read-only copy of the Lua registry.

getgc

table getgc(include_tables?: bool)

Returns a weak table of all Lua objects currently alive according to the garbage collector. By default, tables are not included. Note that some values may immediately be collected after this is called; as such, there will be many gaps in the table.

filtergc

nil | any filtergc(type: string, options: table, return_one?: bool)

Searches for values currently referenced by Lua that match the given criteria. type can either be 'function' or 'table'. Setting return_one indicates that this function should return the first result, or nil if there are no matches. The following options can be used:

Table:

KeyDescriptionDefault
KeysIf not empty, only include tables with keys corresponding to all values in this tablenil
ValuesIf not empty, only include tables with values corresponding to all values in this tablenil
KeyValuePairsIf not empty, only include tables with keys/value pairs corresponding to all values in this tablenil
MetatableIf not empty, only include tables with the metatable passednil

Function:

KeyDescriptionDefault
NameIf not nil, only include functions with this namenil
ConstantsIf not nil, only include functions with constants that match all values in this tablenil
UpvaluesIf not nil, only include functions with upvalues that match all values in this tablenil
IgnoreSynIf false, do not ignore Synapse functions.true
ProtoIf not nil, only include functions with this function prototype.nil
EnvironmentIf not nil, only include functions with this environment.nil
HashIf not nil, only return functions with this hash.nil
StartLineIf not nil, only return functions with this starting line.nil

NOTE; values are compared using bit-for-bit equality checks. This means that NaN == NaN and -0 ~= 0. This allows you to specify NaN or -0 as a value you want to search for.

Examples:

    local empty_table = {
        good = false
    }

    local my_table = {
        good = true,
        one = "two",
        three = "four",
        five = "six",
        v1 = "value one",
    }

    local my_other_table = {
        good = true,
        one = "not two",
        three = "not four",
        five = "six",
        v1 = "value one",
    }

    -- intentionally does not match KeyValuePair, so table should not be found
    local my_bad_table = {
        good = false,
        one = "not two",
        three = "not four",
        v1 = "value one",
        five = "not six",
    }

    for _, v in next, filtergc('table', {
        Keys = { "one", "three" },
        Values = { "value one" },
        KeyValuePairs = {
            five = "six"
        }
    }) do
        assert(v.good)
        warn(v)
    end
    local uv = "bbbbb"
    local function myfunc()
        return "aaaaa" .. uv
    end

    print(filtergc('function', {
        IgnoreSyn = false,
        Name = "myfunc"
    }, true)

    print(filtergc('function', {
        IgnoreSyn = false,
        Constants = { "aaaaa" }
    }, true)

    print(filtergc('function', {
        IgnoreSyn = false,
        Upvalues = { "bbbbb" }
    }, true)

getinstances

table getinstances()

Returns a list of all instances referenced by the current Lua state. Core script references are not included.

getnilinstances

table getnilinstances()

Returns a list of all nil-parented instances referenced by the current Lua state. Core script references are not included.

getscripts

table getscripts()

Returns a list of all loaded scripts in the caller's global state.

getloadedmodules

table getloadedmodules()

Returns a list of all loaded ModuleScripts in the caller's global state.

fireclickdetector

void fireclickdetector(target: Instance)

Emulates clicking a ClickDetector.

fireproximityprompt

void fireproximityprompt(target: Instance)

Emulates triggering a ProximityPrompt. Equivalent to calling replicatesignal on ProximityPrompt.TriggerActionReplicated and ProximityPrompt.TriggerEndedActionReplicated (non-scriptable events).

firetouchinterest

void firetouchinterest(part: Instance, to_touch: Instance, toggle: bool)

Emulates a Touched event on to_touch with part.