Skip to content

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.

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
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
  1. Typecheck with cargo check (Factorio API stubs + Cargo deps).
  2. Discover stage modules (control, settings, data, shared, …).
  3. Lower Rust (syn) into IR (and apply transpile lints).
  4. Optionally prune unreachable code (release-style profiles).
  5. Generate Lua under output_dir (default dist/), including stage entry files and locale .cfg files declared with locale!.

Generated Lua headers look like:

-- Generated by [email protected]
-- Profile: debug
-- Module: `control`

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.

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.