Skip to content

Environment

Functions for accessing and interacting with Lua environments, the garbage collector, and thread management.

getgenv

Returns Volcano's global environment table. This table is shared and replicated across all executor threads.

lua
getgenv() -> table

Example

lua
getgenv().MyGlobalVar = "Hello from Volcano"

-- Accessible from any script running in Volcano
print(getgenv().MyGlobalVar) --> "Hello from Volcano"

getrenv

Returns the game's (Roblox) global environment table.

lua
getrenv() -> table

Example

lua
local renv = getrenv()
print(renv.print) --> function (Roblox's print)
print(renv.game)  --> game

getreg

Returns a read-only copy of the Lua registry.

Aliases: getregistry

lua
getreg() -> table

Example

lua
for i, v in pairs(getreg()) do
    if type(v) == "function" then
        print(i, v)
    end
end

getgc

Returns a weak table containing all Lua objects tracked by the garbage collector.

lua
getgc(include_tables: boolean?) -> table
ParameterTypeDefaultDescription
include_tablesboolean?falseWhether to include tables in the result

Example

lua
for _, v in pairs(getgc()) do
    if type(v) == "function" and getinfo(v).name == "myFunction" then
        print("Found:", v)
    end
end

gettenv

Returns the environment table of the given thread.

lua
gettenv(thread: thread) -> table
ParameterTypeDescription
threadthreadThe thread to get the environment of

Example

lua
local env = gettenv(coroutine.running())
print(env) --> table

getallthreads

Returns a list of all active Lua threads.

lua
getallthreads() -> {thread}

Example

lua
local threads = getallthreads()
print("Total threads:", #threads)

filtergc

Searches the garbage collector for values matching the specified criteria. More efficient than manually iterating getgc().

lua
filtergc(type: string, options: table, return_one: boolean?) -> table | any
ParameterTypeDefaultDescription
typestring"function" or "table"
optionstableSearch criteria (see below)
return_oneboolean?falseIf true, returns the first match instead of a table

Options for "table" type

KeyTypeDescription
KeystableTable must contain these keys
ValuestableTable must contain these values
KeyValuePairstableTable must contain these key-value pairs
MetatabletableTable must have this metatable

Options for "function" type

KeyTypeDescription
NamestringFunction must have this name
ConstantstableFunction must contain these constants
UpvaluestableFunction must contain these upvalues
IgnoreVolcanobooleanIgnore executor functions
EnvironmenttableFunction must have this environment
HashstringFunction must match this hash

Example

lua
-- Find a function by name
local func = filtergc("function", { Name = "onChat" }, true)
print(func) --> function

-- Find a table with specific keys
local results = filtergc("table", { Keys = { "Health", "MaxHealth" } })
for _, tbl in pairs(results) do
    print(tbl.Health, tbl.MaxHealth)
end