Garry's Mod Wiki

debug.getregistry

  table debug.getregistry()

Description

We advise against using this. It may be changed or removed in a future update. This function will return an empty table.
If you get an error because of this see the example below for a workaround

Returns the internal Lua registry table.

The Lua registry is used by the engine and binary modules to create references to Lua values. The registry contains every global ran and used in the Lua environment. Avoid creating entries into the registry with a number as the key, as they are reserved for the reference system.

Improper editing of the registry can result in unintended side effects, including crashing the game.

Returns

1 table
The Lua registry

Example

Workaround if you used this function to get or set metatable functions.
You should switch your code to use FindMetaTable instead of using this function!

local meta = {} function meta.__index(self, key) return FindMetaTable(key) end debug.getregistry = function() local tbl = {} setmetatable(tbl, meta) return tbl end

Example

Let's try to find the global table (_G) inside the registry (_R).

local _R = debug.getregistry() MsgN(_R._LOADED._G) -- _LOADED contains most things ran in Lua, but there are all sorts of other interesting tables inside of the registry. MsgN(_R._LOADED._G == _G)
Output:
table: 0xcece1d62 true