Overview
Use@call_arg when your function wraps a Garry’s Mod API. It lets completion, navigation, type checking, and other editor features treat the wrapper like the original function.
Most addons do not need this annotation. The official annotations already apply it to built-in functions like include, AddCSLuaFile, file.Find, util.AddNetworkString, net.Start, hook.Add, vgui.Register, and derma.DefineSkin.
Only add it when the wrapper has the same behavior as the API it represents.
Wrappers that call the standard GMod network functions are detected automatically. You do not need
@call_arg for normal net.Start, net.Receive, read, write, or send wrappers.Syntax
@call_arg directly above the @param it describes.
path argument as a file loaded by include.
For overloaded signatures, use @overload_call_arg directly above the @overload it describes:
Supported roles
Guard metadata such as
valid_guard, self_guard, and self_call_valid belongs on functions and callbacks, not parameters. Use Guard metadata for functions and callbacks that prove values are valid.
Hooks with callbacks
Use one role for the hook name and one role for the callback function:emit for functions that call hooks:
Lua loading
Usegmod.load for wrappers around Lua file and module loading:
include, AddCSLuaFile, IncludeCS, and require calls. GLuaLS follows fixed paths and file.Find loops when it can identify the matching files.
Use gmod.file_find when wrapping file.Find itself:
FindLuaFiles("myaddon/*.lua", "LUA") is used in a loop and the loop body calls annotated load wrappers, GLuaLS can infer which matching files are loaded server-side, sent to the client, or shared.
VGUI panels
Usedefine, table, and base for a vgui.Register wrapper:
define_control instead of define for derma.DefineControl wrappers. Use reference for functions that create or look up panels by name.
Derma skins
Usegmod.derma_skin when wrapping Derma skin functions:
DefineSkin("MySkin", ...) and UseSkin("MySkin").
Scripted classes
Usegmod.network_var when wrapping entity NetworkVar helpers:
define_element for wrappers around NetworkVarElement, because element accessors always return numbers.
For gamemode inheritance wrappers, mark the base-name parameter:
gmod.class_base reference for wrappers around DEFINE_BASECLASS.
Priority
An optional third argument breaks ties when one parameter can inherit multiple roles:See also
- Realm awareness: realm inference from file loading
- Network analysis: net message tracking
- Hook intelligence: hook completion and callback inference
- VGUI support: panels and Derma skins
- Guard metadata: validity guards for nil and NULL checks