Getting Started
This guide walks through the smallest useful Lux workflow during the alpha:
install or build luxc, compile one file, write a multi-part module, then
build a GMod addon layout.
Requirements
Lux currently targets Lua 5.1 / GLua. For normal addon work you need:
- A Lux alpha release, or a Rust toolchain if you want to build
luxcfrom source. - A Garry's Mod addon directory when testing generated artifacts in game.
- Optional
gmad.exewhen packaging.gmafiles.
Download the current alpha release from the Lux repository, extract it, and run the installer script from the extracted directory:
If you want the current checkout instead of the published prerelease, build from source and install that executable:
The installed user entrypoint is %USERPROFILE%\.lux\bin\luxc.exe on Windows.
If you skip installation, call the explicit build output instead:
The examples below assume luxc is on PATH.
Compile One File
Start with a single file:
Single-file compilation is useful for checking syntax, generated Lua shape, and
small language examples. GMod projects normally use luxc gmod build so the
compiler can discover modules, split realms, and emit loaders.
The repository's examples/features.lux is deliberately a single-file syntax
tour. It does not teach imports, exports, packages, macros, or top-level realm
ownership. Use examples/gmod_project for the project/module model.
Write a First Module
Create a module directory. A multi-file module needs an entry part.
The entry part is where the public module shape and part order are easiest to find.
Server parts can use the private function from the entry part without importing it. All parts in the same module share module-private scope.
Client parts can expose client-only UI without leaking it into the server artifact.
The module has one public API, but each exported name is available only in the realm where it is valid.
Create a GMod Project
Create a project skeleton. Plain init is offline and writes no dependencies:
Add the official standard package set when your project imports packages such
as @lux/std or @lux/gmod:
Create lux.toml at the project root:
Lux has no package registry. lux.toml chooses concrete package sources with
github, url, or path, and can pin GitHub package sets with tag,
branch, or commit. lux.lock records the resolved package graph.
Recommended layout:
Build GMod artifacts:
The build step discovers modules under source_root, infers realms from file
prefixes and folders, resolves package imports, emits Lua artifacts under
out, writes a relative-path-safe Lux loader tree under runtime_base, and
writes an optional addon autorun forwarder.
Build from Explicit Paths
For experiments and CI slices, you can build from an explicit source root and output root:
Use a manifest for real projects. It keeps package ids, output roots, source map settings, autorun policy, and extern policy in one stable place.
Check and Format
Run linting without emitting artifacts:
Format a file:
Format whole project sources through your editor or a script until the CLI grows full project formatting commands.
Map Runtime Errors
GMod reports Lua stack traces. Lux emits source maps so you can map generated Lua locations back to Lux source.
With readable source comments enabled, generated Lua also contains source
anchors around functions and branch blocks. Use source_comments = "none" for
production-sized artifacts and sidecar source maps for debugging.