RuneScript Compiler (runec)
A compiler for RuneScript (.rs2), the scripting language used by RuneScape's game engine. Compiles source scripts into binary script.dat/script.idx output consumed by the game server.
Prerequisites
Installation
Windows (PowerShell)
powershell -ExecutionPolicy Bypass -File install.ps1
Linux / macOS / Git Bash
This builds the compiler in release mode and installs it to ~/.runec/bin as runec. The install script adds the directory to your PATH and creates a shell alias. Restart your terminal after installation.
Usage
Compiling Scripts
Compiles all .rs2 files in the source directory and writes script.dat and script.idx to the output directory.
# Compile with default output (./data/pack/server)
# Specify both source and output
# Provide an explicit pack directory for symbol resolution
# Compile and run lint passes
The compiler runs the following phases in order:
- Parse -- Lexes and parses all
.rs2files into an AST - Symbol registration -- Registers script names, loads entity pack files (items, NPCs, interfaces, etc.), engine commands, and constants
- Type check -- Validates types, resolves references, and checks trigger signatures across all scripts
- Code generation -- Emits bytecode from the AST
- Pointer check -- Static analysis for active-entity pointer hazards (warnings)
- Lint (optional) -- Detects unused locals and unreachable code (warnings)
- Write output -- Writes compiled
script.datandscript.idx
Linting Scripts
Run all analysis passes without writing any output:
# With explicit pack directory
This runs the full pipeline (parse, type-check, codegen, pointer-check, lints) and reports diagnostics. Useful for editor tooling and CI lint gates.
Performance
runec runs its heavy phases — parsing, type-checking, code generation,
pointer analysis, and output encoding — in parallel across all available
cores, while producing byte-for-byte identical output to a single-threaded
run (verified against the reference compiler on full 225 and 647 script sets).
On a 1,100+ file script set it compiles in roughly half a second — about 6×
faster than 0.2.x on a multi-core machine. Release builds use fat LTO for
additional throughput.
Development
Building from Source
Running Tests
Running without Installing
Library Usage
The compiler is also available as a library crate on crates.io.
Installation
Or add it to your Cargo.toml manually:
[]
= "0.3.1"
Example
use Path;
// Compile scripts and write output
compile.unwrap;
// Lint only (no output written)
lint.unwrap;
License
This project is licensed under the MIT License.