Skip to main content

Overview

Garry’s Mod uses a “scripted class” pattern. You define a global table, such as ENT or SWEP, in a specific file location, and GMod registers it as a class. GLuaLS detects these classes and provides:
  • Class registration including inheritance
  • Synthesis of NetworkVar getter/setter pairs
  • Synthesis of AccessorFunc getter/setter pairs
  • Better completions and type checking for scripted class code

Automatic detection

GLuaLS detects the standard class table from the file’s project folder. For example: GLuaLS types the detected class table with the base class’s methods and fields, so you get completions and type checking without annotations. Schemas work automatically for any framework or gamemode. GLuaLS treats SCHEMA and Schema as aliases for one global schema table, merges members declared across schema files, and exposes gamemode hooks inherited from GM. The schema remains available to files outside the schema/ directory, matching the usual runtime behavior of global schema systems. Player classes, plugins, and custom project layouts are also supported through the scripted class settings.

AccessorFunc methods

AccessorFunc(table, member, name, ...) creates getter and setter methods. GLuaLS adds those methods to completion and type checking:
Use the ---@accessorfunc annotation for custom getters and setters. See @accessorfunc for details.

NetworkVar methods

ENT:NetworkVar(type, slot, name, ...) creates entity accessors. GLuaLS adds the matching methods:
You get completions and type checking for generated accessors without manual annotations.

Supported NetworkVar types


Base class inheritance

Scripted classes in GMod inherit from base classes. GLuaLS understands this chain and suggests inherited methods. The scripted class table also gets the standard base type for that scope, such as Entity, Weapon, or Tool. DEFINE_BASECLASS(...) and values like ENT.Base can refine that type further.
For gamemodes that derive from another gamemode, such as DarkRP deriving from Sandbox, GLuaLS adds the parent’s folder as a library. See Gamemode inheritance to configure or disable this.

Hook overrides in scripted classes

GLuaLS treats functions defined in a scripted class table as engine hook overrides for that class:
Completions suggest the correct signature for each override.

Class Explorer integration

The VS Code Class Explorer lists detected scripted classes. You can browse groups, such as entities, weapons, effects, and custom scopes, and jump to class definitions. Class grouping and labels come from gmod.scriptedClassScopes.include.

Scaffolding integration

Scripted class scopes also control class scaffolding. Each scope can define scaffold output files with scaffold.files and a rootDir in gmod.scriptedClassScopes.include. You can create new classes with your own template layout while GLuaLS keeps class analysis, explorer grouping, and generated files in sync. See Garry’s Mod settings for all supported fields.

Creating a new class

  1. Open the Class Explorer in the sidebar.
  2. Find the group you want, such as Entities.
  3. Click the + button next to that group.
  4. Enter the class name.
  5. The VS Code extension creates the files and opens the main file.

Built-in templates

The VS Code extension includes built-in templates for the standard scripted class types:

Custom class scopes

If you use a non-standard directory structure or custom class types, configure GLuaLS to recognize them:
Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
.gluarc.json

Fields


Disabling a scripted class group

To disable a built-in scripted class scope, add an override with the same id and set "disabled": true.
.gluarc.json