Skip to main content

Overview

@enum marks a local table as an enum type. Table values become valid enum members. GLuaLS can report invalid enum values with enum-value-mismatch when you enable that diagnostic.

Syntax


Basic enum


String enums


(key) modifier

Use (key) when the table keys are the enum values:

Enum vs. @alias

Both @enum and @alias with ---| can describe a fixed set of values. Use:
  • @enum when your addon has a Lua table of named constants that code reads at runtime
  • @alias with ---| when a string parameter accepts a fixed set of text values

Common patterns in GMod

GMod’s built-in enums, such as DAMAGE, TEAM, and MOVETYPE, come from the downloaded annotations. You do not need to redeclare them.