AcediaDocumentation

getthreadenvironment

Returns the environment a thread resolves global names through.

Answers with the environment of the innermost Lua function on the thread rather than the thread's globals table, because a chunk running under a custom environment hands that environment to the threads it spawns. A thread with no Lua frame falls back to its globals table.

getthreadenvironment(thread: thread): table

Parameters

ParameterTypeDescription
threadthreadThread to inspect.

Example

print(getthreadenvironment(coroutine.running()) == getfenv(1))

Example output

true

Errors: A thread with no readable environment raises an error.

On this page