GMod Backend
luxc gmod build turns Lux source modules into Garry's Mod Lua artifacts. The
backend is responsible for discovery, realm splitting, the Lux loader tree,
optional autorun forwarding, AddCSLuaFile routing, source maps, and package
integration.
What the Backend Does
The GMod backend performs these steps:
The result is a relative-path-safe Lua output tree. Addon projects normally put
that tree under generated/lua; gamemodes or framework integrations can point
out somewhere else and include the loaders manually.
The backend does not assume every project owns lua/autorun. Plain init
defaults to addon-friendly output, but autorun = false is enough when another
entry point should own startup.
Minimal Configuration
package_id identifies the current project package. bundle_id is used in
generated registry names and default paths. out is the physical output root.
runtime_base is the GMod-relative path used by generated include and
AddCSLuaFile calls. autorun = true writes an addon-style forwarder under
out/autorun; set it to false when another entry point owns startup.
Generated Layout
Typical output:
The exact file density may change as module merging improves, but the generated
root remains build output. Source files stay under src/.
Build Commands
Build through the manifest:
Build with explicit paths:
For production-sized source comments, set this in lux.toml:
Use source maps to map runtime Lua stack traces back to Lux source:
Realm Artifacts
Realm blocks and realm declarations control which artifact receives code.
The checker uses the inner active realm for PhysicsInitBox, so server-only
uses inside the block are accepted even when the surrounding function is shared.
Package as GMA
After building, package the addon with GMod tools from the addon root. If
out = "generated/lua", the package root is usually generated:
Keep generated output under the package root if it should be included in the
GMA. out itself is not necessarily the package root.
Development Recommendations
- Keep
src/andgenerated/separate. - Put complete
part orderin the module entry part when initialization order matters. - Prefer
cl_,sv_, andsh_prefixes for files that map naturally to GMod convention. - Use realm blocks for fine-grained server/client code inside shared hooks.
- Treat unknown external warnings as work items; add
externdeclarations for third-party APIs you rely on. - Do not hand-write
AddCSLuaFilefor Lux modules. The generated Lux loader owns client file routing. Ifautorun = false, include the generated loaders from your own entry point.