Type tracking
The server understands how common GLua functions transform types and propagates that knowledge through your code.Player lookup
When you callplayer.GetByID, the server knows the result is a Player entity:
Panel creation
vgui.Create with a known panel class returns that type:
Loop iteration
ipairs over a player list types each element as Player:
Typed hook sender
When you register a hook with a typed sender parameter, the callback receives the correct type:Entity methods
InsideENT methods, self is typed as Entity:
Typing your own functions
You can add explicit types to your own functions with annotations, or let the server infer them from usage.Supported annotation tags
GLua Language Server uses the same annotation dialect as Lua Language Server.
You can also use union types, optional parameters, and array syntax:
How inference falls back
When the server cannot determine an exact type, it uses the following strategy:- Ambiguous sets — If an object could be one of several types, the server finds the most specific common base class. For example, a value that is sometimes a
Playerand sometimes anNPCfalls back toEntity. - Unrecognisable values — If a type cannot be inferred at all, it falls back to
any. You will still get generic Lua completions, but no Garry’s Mod specific methods. - Explicit annotations always win — If you add a
---@typeor---@paramannotation, it overrides any inferred type.