Skip to main content

global

Miscellaneous

This is not a library! It represents any globals pushed to the thread's environment!

Properties

_RENV

Global
global._RENV: {[any]any}

The global roblox environment, as a table.

_GENV

Global
global._GENV: {[any]any}

The global executor environment, as a table.

_ENV

Global
global._ENV: {[any]any}

The current thread's environment, as a table.

Functions

gettenv

Global
global.gettenv(
threadthread--

The thread to fetch the environment of.

) → {[any]any}--

The environment of the thread.

Fetches the environment of a thread.

httpget

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsGlobal
global.httpget(
urlstring--

The URL to send the request to.

) → string--

The body of the response.

Fetches the Body of an HTTP server using a GET HTTP request.

Errors

TypeDescription
Invalid protocol (expected 'http://' or 'https://')The provided URL is not on the form of an HTTP request.

messagebox

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsGlobal
global.messagebox(
textstring,--

The text to display in the message box.

captionstring,--

The caption to display in the message box.

flagsnumber--

The flags to apply to the message box.

) → number--

The result of the message box.

Creates a Win32 MessageBox with the provided text, caption, and flags. Yields until the message box is closed.

Errors

TypeDescription
Win32 error '%s'An error occured while trying to display the messagebox. The Win32 error will be in-place of the '%s'.

getgenv

Global
global.getgenv() → {[any]any}--

The global environment of the executor.

Obtains the global environment of the executor. Contains all of rSUNC globals.

Sandboxing

All threads must be sandboxed. This means that modifications to the current thread's global environment should NOT pollute the result of getgenv.

Modifications done to the table returned by getgenv must be observable to all threads an executor makes, but not observable to other threads within the VM, such as game threads.

Example:


do
    -- Thread 1
    HelloVariable = "Hello"
    print(HelloVariable) -- prints 'Hello'
    print(HelloVariableViaGetGenv)  -- prints 'nil'
    print(getgenv().HelloVariableViaGetGenv)  -- prints 'nil'    

    getgenv().HelloVariableViaGetGenv = HelloVariable -- Set HelloVariableViaGetGenv to the value of HelloVariable (can be observed by Thread 2!)
    print(HelloVariable) -- prints 'Hello'
    print(HelloVariableViaGetGenv)  -- prints 'Hello'
    print(getgenv().HelloVariableViaGetGenv)  -- prints 'Hello'
end
-- ...
do
    -- Thread 2 (runs after thread 1)
    print(HelloVariable) -- prints 'nil'
    print(HelloVariableViaGetGenv)  -- prints 'Hello'
    print(getgenv().HelloVariableViaGetGenv)  -- prints 'Hello'
end

getrenv

Global
global.getrenv() → {[any]any}--

The global environment of main thread of Luau.

Returns the global environment of main thread of Luau. This environment is different from the executor environment.

Sandboxing

You must NOT modify this environment under ANY circumstance. ANY modification will be observable by all threads in the VM.

getreg

Global
global.getreg() → {[any]any}--

The Luau registry

Returns the Luau registry.

getscriptglobals

Global
global.getscriptglobals() → {
_G{[any]any},
shared{[any]any}
}

Returns the _G and shared script globals.

Show raw api
{
    "functions": [
        {
            "name": "gettenv",
            "desc": "Fetches the environment of a thread.",
            "params": [
                {
                    "name": "thread",
                    "desc": "The thread to fetch the environment of.",
                    "lua_type": "thread"
                }
            ],
            "returns": [
                {
                    "desc": "The environment of the thread.",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 42,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "httpget",
            "desc": "Fetches the Body of an HTTP server using a GET HTTP request.",
            "params": [
                {
                    "name": "url",
                    "desc": "The URL to send the request to.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The body of the response.",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "errors": [
                {
                    "lua_type": "Invalid protocol (expected 'http://' or 'https://')",
                    "desc": "The provided URL is not on the form of an HTTP request."
                }
            ],
            "yields": true,
            "source": {
                "line": 56,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "messagebox",
            "desc": "Creates a Win32 MessageBox with the provided text, caption, and flags. Yields until the message box is closed.",
            "params": [
                {
                    "name": "text",
                    "desc": "The text to display in the message box.",
                    "lua_type": "string"
                },
                {
                    "name": "caption",
                    "desc": "The caption to display in the message box.",
                    "lua_type": "string"
                },
                {
                    "name": "flags",
                    "desc": "The flags to apply to the message box.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "The result of the message box.",
                    "lua_type": "number"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "errors": [
                {
                    "lua_type": "Win32 error '%s'",
                    "desc": "An error occured while trying to display the messagebox. The Win32 error will be in-place of the '%s'."
                }
            ],
            "yields": true,
            "source": {
                "line": 72,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "getgenv",
            "desc": "Obtains the global environment of the executor. Contains all of rSUNC globals.\n\n\n:::info Sandboxing\nAll threads must be sandboxed. This means that modifications to the current thread's global environment should __NOT__ pollute the result of `getgenv`.\n\nModifications done to the table returned by `getgenv` must be observable to all threads an executor makes, but not observable to other threads within the VM, such as game threads.\n:::\n\n### Example:\n```lua\n\ndo\n    -- Thread 1\n    HelloVariable = \"Hello\"\n    print(HelloVariable) -- prints 'Hello'\n    print(HelloVariableViaGetGenv)  -- prints 'nil'\n    print(getgenv().HelloVariableViaGetGenv)  -- prints 'nil'    \n\n    getgenv().HelloVariableViaGetGenv = HelloVariable -- Set HelloVariableViaGetGenv to the value of HelloVariable (can be observed by Thread 2!)\n    print(HelloVariable) -- prints 'Hello'\n    print(HelloVariableViaGetGenv)  -- prints 'Hello'\n    print(getgenv().HelloVariableViaGetGenv)  -- prints 'Hello'\nend\n-- ...\ndo\n    -- Thread 2 (runs after thread 1)\n    print(HelloVariable) -- prints 'nil'\n    print(HelloVariableViaGetGenv)  -- prints 'Hello'\n    print(getgenv().HelloVariableViaGetGenv)  -- prints 'Hello'\nend\n\n```",
            "params": [],
            "returns": [
                {
                    "desc": "The global environment of the executor.",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 114,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "getrenv",
            "desc": "Returns the global environment of main thread of Luau. This environment is __different__ from the executor environment.\n\n\n:::info Sandboxing\nYou must __NOT__ modify this environment under __ANY__ circumstance. __ANY__ modification will be observable by all threads in the VM.\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "The global environment of main thread of Luau.",
                    "lua_type": "{[any]: any}"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 129,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "getreg",
            "desc": "Returns the Luau registry.",
            "params": [],
            "returns": [
                {
                    "desc": "The Luau registry",
                    "lua_type": "{[any]: any}"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 140,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "getscriptglobals",
            "desc": "Returns the `_G` and `shared` script globals.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ _G: {[any]: any}, shared: {[any]: any} }"
                }
            ],
            "function_type": "static",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 152,
                "path": "impl/Libraries/global.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "_RENV",
            "desc": "The global roblox environment, as a table.\n    ",
            "lua_type": "{ [any]: any }",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 16,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "_GENV",
            "desc": "The global executor environment, as a table.\n    ",
            "lua_type": "{ [any]: any }",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 24,
                "path": "impl/Libraries/global.luau"
            }
        },
        {
            "name": "_ENV",
            "desc": "The current thread's environment, as a table.\n    ",
            "lua_type": "{ [any]: any }",
            "tags": [
                "Global"
            ],
            "source": {
                "line": 31,
                "path": "impl/Libraries/global.luau"
            }
        }
    ],
    "types": [],
    "name": "global",
    "desc": "This is not a library! It represents any globals pushed to the thread's environment!",
    "tags": [
        "Miscellaneous"
    ],
    "source": {
        "line": 7,
        "path": "impl/Libraries/global.luau"
    }
}