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.

Piece Crate / binary Role
SDK factorio-rs Dependency for your mod crate (API stubs + macros)
CLI package factorio-rs-cli, binary factorio-rs init, build, package, install, open
  1. Discover stage modules (control, settings, data, shared, …).
  2. Lower Rust (syn) into IR.
  3. Optionally prune unreachable code (release-style profiles).
  4. 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 factorio-rs@0.1.2
-- Profile: debug
-- Module: `control`
  • cargo check / cargo build validate your Rust (macros, types).
  • factorio-rs build does not invoke Cargo; it transpiles sources directly.

You typically iterate with both: check with Cargo, emit the mod with the CLI.

Only a subset of Rust is transpiled. See Language support for statements, expressions, Option / Vec behaviour, and common unsupported constructs. Optional Tracing macros lower to colored game.print. Generated API stubs prefer concrete concepts and Identification enums over LuaAny.