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:
Key | Description | Default |
---|---|---|
Keys | If not empty, only include tables with keys corresponding to all values in this table | nil |
Values | If not empty, only include tables with values corresponding to all values in this table | nil |
KeyValuePairs | If not empty, only include tables with keys/value pairs corresponding to all values in this table | nil |
Metatable | If not empty, only include tables with the metatable passed | nil |
Function:
Key | Description | Default |
---|---|---|
Name | If not nil, only include functions with this name | nil |
Constants | If not nil, only include functions with constants that match all values in this table | nil |
Upvalues | If not nil, only include functions with upvalues that match all values in this table | nil |
IgnoreSyn | If false, do not ignore Synapse functions. | true |
Proto | If not nil, only include functions with this function prototype. | nil |
Environment | If not nil, only include functions with this environment. | nil |
Hash | If not nil, only return functions with this hash. | nil |
StartLine | If 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 ModuleScript
s 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
.