debug.getregistry

From GMod Wiki

Jump to: navigation, search
Function
Syntax debug.getregistry( )
Where is this used?
Description:
Returns the registry table.
Returns: Table
Part of Library: Debug
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Debug.getregistry]Debug.getregistry [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionWrites the contents of the registry to a file named "registry_dump.txt" in the gmod data folder
Used onNewerShared.png
Code
local registryTable = debug.getregistry()
file.Write("registry_dump.txt", table.ToString(registryTable, "registry", true))
OutputN/A

Detailed Description

(from the Lua 5.1 reference manual)

Lua provides a registry, a pre-defined table that can be used by any C code to store whatever Lua value it needs to store. This table is always located at pseudo-index LUA_REGISTRYINDEX. Any C library can store data into this table, but it should take care to choose keys different from those used by other libraries, to avoid collisions. Typically, you should use as key a string containing your library name or a light userdata with the address of a C object in your code.

The integer keys in the registry are used by the reference mechanism, implemented by the auxiliary library, and therefore should not be used for other purposes.

Note

In Garry's Mod, the registry is also accessible through the global variable _R, which is the preferred way to access it.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox