gettenv
Gets the environment of a thread.
Syntax
gettenv(thread: thread?) -> tableParameters
| Parameter | Type | Description |
|---|---|---|
thread | thread | (Optional) Thread, defaults to current |
Returns
| Type | Description |
|---|---|
table | The 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)