Translations:Extension:Scribunto/Lua reference manual/1340/en

Global variables are stored in a standard Lua table called an environment; this table is often available as the global variable. It is possible to set a metatable for this global variable table; the __index and __newindex metamethods will be called for accesses of and assignments to global variables just as they would for accesses of and assignments to fields in any other table.