Syntax
getscriptglobals(): tableReturns
| Name | Type | Description |
|---|---|---|
globals | table | Fresh table with _G and shared fields copied from LUA_GLOBALSINDEX. |
Description
Returns a new table containing the current LUA_GLOBALSINDEX values for _G and shared. The function takes no arguments, creates a fresh table, assigns _G from LUA_GLOBALSINDEX._G and shared from LUA_GLOBALSINDEX.shared, and returns exactly one value. It does not return the full global table, and no alias is registered for getscriptglobals.
Call it without parameters. The function reads the needed context from the current runtime state.
It returns globals (table). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Read the _G and shared values copied from LUA_GLOBALSINDEX.
local globals = getscriptglobals()
print(globals._G)
print(globals.shared)