Volt

gettenv

Gets the environment of a thread.

Syntax

gettenv(thread: thread?) -> table

Parameters

ParameterTypeDescription
threadthread(Optional) Thread, defaults to current

Returns

TypeDescription
tableThe thread's environment

Description

gettenv returns the environment table for the specified thread. If no thread is provided, returns the current thread's environment.

Example

-- Get current thread's environment
local env = gettenv()
print(env.print) -- The print function

-- Get another thread's environment
local thread = coroutine.create(function() end)
local threadEnv = gettenv(thread)

On this page