Global Variables
Global Variables
Global Tables
There are various global tables containing the active game
state some of which are only available in specific scopes.
Variable | Value | Scope |
---|---|---|
GAMEMODE |
The active gamemode | Available anywhere Only available if the gamemode has been loaded |
GM |
The loading gamemode | Available inside the gamemode's files Only available while the gamemode is loading gamemodes/<Gamemode>/gamemode/*.lua |
ENT |
The current scripted entity | Available inside the entity's files lua/entities/*.lua |
SWEP |
The current scripted weapon | Available inside the weapon's files lua/weapons/*.lua |
EFFECT |
The current scripted effect | Available inside the effect's files lua/effects/*.lua |
_G |
All globals, including itself | Available anywhere |
_MODULES |
List of all /modules/ |
Available anywhere |
NON CONSTANTS
CLIENT
This is true whenever the current script is executed on the client. ( client and menu states ) See States. Always present.
CLIENT_DLL
This is true whenever the current script is executed on the client state. See States.
SERVER
This is true whenever the current script is executed on the server state. See States. Always present.
GAME_DLL
This is true whenever the current script is executed on the server state.
MENU_DLL
This is true when the script is being executed in the menu state. See States.
GAMEMODE_NAME
Contains the name of the current active gamemode.
NULL
Represents a non existent entity.
VERSION
Contains the version number of GMod. Example: "201211"
VERSIONSTR
Contains a nicely formatted version of GMod. Example: "2020.12.11"
BRANCH
The branch the game is running on. This will be "unknown"
on main branch. While this variable is always available in the Client & Menu realms, it is only defined in the Server realm on local servers.
_VERSION
Current Lua version. This contains "Lua 5.1"
in GMod at the moment.
NETVERSIONSTR
Contains the current networking version. Example: "2023.06.28"
g_ Shortcuts
CONSTANTS
MISC
ENUMS
Almost all enumerations are globals.