Introduction
factorio-rs lets you write Factorio mods in Rust. A CLI tool reads your .rs
sources, lowers them through an intermediate representation, and emits a
standard Factorio mod (Lua + info.json + optional locale).
It does not compile Rust to native code or WASM for Factorio. The game still loads Lua. Think of factorio-rs as an authoring layer that transpiles to Factorio’s modding API.
Start here
Section titled “Start here”| Path | Why |
|---|---|
| Installation | CLI + SDK + Factorio path |
| Getting started | init -> build -> install |
| First hour | Same loop plus your first in-game test |
| Recipes | Concrete jobs (storage, settings, enums, …) |
| Discord | Community help and announcements |
Pieces
Section titled “Pieces”| Piece | Crate / binary | Role |
|---|---|---|
| SDK | factorio-rs |
Dependency for your mod crate (API stubs + macros) |
| CLI | package factorio-rs-cli, binary factorio-rs |
init, check, build, package, install, add, open, test |
Pipeline
Section titled “Pipeline”- Typecheck with
cargo check(Factorio API stubs + Cargo deps). - Discover stage modules (
control,settings,data,shared, …). - Lower Rust (
syn) into IR (and apply transpile lints). - Optionally prune unreachable code (release-style profiles).
- Generate Lua under
output_dir(defaultdist/), including stage entry files and locale.cfgfiles declared withlocale!.
Generated Lua headers look like:
-- Generated by [email protected]-- Profile: debug-- Module: `control`Typechecking
Section titled “Typechecking”factorio-rs check and factorio-rs build run cargo check first against the
Factorio API stubs (methods, arity, ordinary Rust types), then validate that
sources can be lowered (and apply transpile lints). Use --skip-typecheck only
as an escape hatch.
cargo check / rust-analyzer alone are still useful for editor feedback.
Notable releases are listed in the changelog.
Language surface
Section titled “Language surface”Only a subset of Rust is transpiled. See Supported Rust for
the inventory, Option and Result for nil / errors,
and Enums / Collections for focused
pages. Transpile-time Lints catch traps that type-check in Rust
but miscompile in Lua. Optional Tracing and
Serde / JSON lower to Factorio builtins. Generated API stubs
prefer concrete concepts and Identification enums over
LuaAny.