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() -> tableExample
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() -> tableExample
lua
local renv = getrenv()
print(renv.print) --> function (Roblox's print)
print(renv.game) --> gamegetreg
Returns a read-only copy of the Lua registry.
Aliases: getregistry
lua
getreg() -> tableExample
lua
for i, v in pairs(getreg()) do
if type(v) == "function" then
print(i, v)
end
endgetgc
Returns a weak table containing all Lua objects tracked by the garbage collector.
lua
getgc(include_tables: boolean?) -> table| Parameter | Type | Default | Description |
|---|---|---|---|
include_tables | boolean? | false | Whether 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
endgettenv
Returns the environment table of the given thread.
lua
gettenv(thread: thread) -> table| Parameter | Type | Description |
|---|---|---|
thread | thread | The thread to get the environment of |
Example
lua
local env = gettenv(coroutine.running())
print(env) --> tablegetallthreads
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| Parameter | Type | Default | Description |
|---|---|---|---|
type | string | — | "function" or "table" |
options | table | — | Search criteria (see below) |
return_one | boolean? | false | If true, returns the first match instead of a table |
Options for "table" type
| Key | Type | Description |
|---|---|---|
Keys | table | Table must contain these keys |
Values | table | Table must contain these values |
KeyValuePairs | table | Table must contain these key-value pairs |
Metatable | table | Table must have this metatable |
Options for "function" type
| Key | Type | Description |
|---|---|---|
Name | string | Function must have this name |
Constants | table | Function must contain these constants |
Upvalues | table | Function must contain these upvalues |
IgnoreVolcano | boolean | Ignore executor functions |
Environment | table | Function must have this environment |
Hash | string | Function 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