Garry's Mod Wiki


The engine library provides functions to access various features in the game's engine, most are related to the demo and save systems.


string engine.ActiveGamemode()
Returns the name of the currently running gamemode.
Closes the server and completely exits. This is only functional when running in server test mode (launch option -systemtest). Server test mode is used internally at Facepunch as part of the build process to make sure that the dedicated servers aren't crashing on startup.
table engine.GetAddons()
Returns a list of addons the player have subscribed to on the workshop. This list will also include "Floating" . gma addons that are mounted by the game, but not the folder addons.
number engine.GetDemoPlaybackStartTick()
When starting playing a demo, engine.GetDemoPlaybackTick will be reset and its old value will be added to this functions return value.
number engine.GetDemoPlaybackTick()
Current tick of currently loaded demo. If not playing a demo, it will return amount of ticks since last demo playback.
number engine.GetDemoPlaybackTimeScale()
Returns time scale of demo playback. If not during demo playback, returns 1.
number engine.GetDemoPlaybackTotalTicks()
Returns total amount of ticks of currently loaded demo. If not playing a demo, returns 0 or the value of last played demo.
table engine.GetGamemodes()
Returns a table containing info for all installed gamemodes
table engine.GetGames()
Returns an array of tables corresponding to all games from which Garry's Mod supports mounting content.
table engine.GetUserContent()
We advise against using this. It may be changed or removed in a future update. Used internally for in-game menus, may be merged in the future into engine.GetAddons. Returns the UGC (demos, saves and dupes) the player have subscribed to on the workshop.
boolean engine.IsPlayingDemo()
Returns true if we're currently playing a demo. You will notice that there's no server-side version of this. That's because there is no server when playing a demo. Demos are both recorded and played back purely clientside.
boolean engine.IsRecordingDemo()
Returns true if the game is currently recording a demo file (.dem) using gm_demo
engine.LightStyle( number lightstyle, string pattern )
This is a direct binding to the function engine->LightStyle. This function allows you to change the default light style of the map - so you can make lighting lighter or darker. You’ll need to call render.RedownloadAllLightmaps clientside to refresh the lightmaps to this new color. Calling this function with arguments 0 and "a" will cause dynamic lights such as those produced by the Light tool to stop working.Issue Tracker: 3626
string engine.OpenDupe( string dupeName )
Loads a duplication from the local filesystem.
number, number engine.ServerFrameTime()
Returns an estimate of the server's performance. Equivalent to calling FrameTime from the server, according to source code.
engine.SetMounted( string depotID, boolean doMount )
Sets the mounting options for mountable content.
number engine.TickCount()
Returns the number of ticks since the game server started.
number engine.TickInterval()
Returns the number of seconds between each gametick.
table engine.VideoSettings()
Returns video recording settings set by video.Record. Used by Demo-To-Video feature.
engine.WriteDupe( string dupe, string jpeg )
Saves a duplication as a file.
engine.WriteSave( string saveData, string name, number time, string map )
Stores savedata into the game (can be loaded using the LoadGame menu)