Getting started
Create a project
Section titled “Create a project”mkdir my-mod && cd my-modfactorio-rs init --name my-modinit refuses to overwrite an existing Cargo.toml or Factorio.toml.
What gets created
Section titled “What gets created”| Path | Purpose |
|---|---|
Cargo.toml |
Library crate depending on factorio-rs |
Factorio.toml |
Transpile + mod metadata |
src/lib.rs |
Sample control_mod! with one event |
.gitignore |
Ignores /target, /dist, /.factorio-rs/..., /*.zip |
Default src/lib.rs:
factorio_rs::control_mod! { #[factorio_rs::event(OnSingleplayerInit)] pub fn on_singleplayer_init() { println!("Initialized"); }}Configure
Section titled “Configure”Minimal Factorio.toml:
source = "src"output_dir = "dist"
[mod]title = "Factorio Mod"factorio_version = "2.0"
[profiles.debug]debug_level = 1prune_dead_code = falseoptimize_ir = false
[profiles.release]debug_level = 0prune_dead_code = trueoptimize_ir = truefactorio-rs check # cargo check + transpile lints (no output)factorio-rs build # typecheck, then transpile into dist/Typical output:
dist/ info.json control.lua lua/control.luaEach build wipes output_dir before writing.
Install and play
Section titled “Install and play”factorio-rs install # copy dist/ -> mods/<name>_<version>/factorio-rs install --open # install, then launch Factoriofactorio-rs package # release profile and zip at project rootZip name: {cargo_package_name}_{version}.zip with a Factorio-ready root
folder inside.
Place an optional thumbnail.png in the project root (or set
[mod].thumbnail) so it is copied into the mod for the Factorio mod portal.
List graphics, sounds, and other files under [mod].assets so they are packaged
into the mod output (see Factorio.toml).
End-to-end item registration: Package graphics.
Next steps
Section titled “Next steps”- First hour - see a print in-game, then run
factorio-rs test - Pick a recipe: storage, settings, enums, graphics
- Deeper reading: Supported Rust, Option and Result, Testing, Stages
- Example: hello_world