Skip to content

getgenv

getgenv polluting

Modifications to a thread's global environment should not affect getgenv.

getgenv returns the executor's global environment table, which is shared across all executor-made threads.

This environment is writable and persistent during the session, making it useful for sharing state or functions across different scripts.

function getgenv(): { any }

Parameters

Parameter Description
(none) This function takes no parameters.

Example

getgenv shouldn't be affected by the global table/getfenv
1
2
3
4
5
6
7
8
getgenv().dummy_val = "value"
getfenv().dummy_val_2 = 1

print(dummy_val, getgenv().dummy_val_2) -- Output: value, 1

getgenv().dummy_val = "value2"
dummy_val = nil
print(dummy_val) -- Output: value2