Skip to content

Getting started

Terminal window
mkdir my-mod && cd my-mod
factorio-rs init --name my-mod

init refuses to overwrite an existing Cargo.toml or Factorio.toml.

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, /*.zip

Default src/lib.rs:

factorio_rs::control_mod! {
#[factorio_rs::event(OnSingleplayerInit)]
pub fn on_singleplayer_init() {
println!("Initialized");
}
}

Minimal Factorio.toml:

source = "src"
output_dir = "dist"
[mod]
title = "Factorio Mod"
factorio_version = "2.0"
[profiles.debug]
debug_level = 1
prune_dead_code = false
[profiles.release]
debug_level = 0
prune_dead_code = true
Terminal window
cargo check # type-check Rust + macros
factorio-rs build # transpile into dist/

Typical output:

dist/
info.json
control.lua
lua/control.lua

Each build wipes output_dir before writing.

Terminal window
factorio-rs install # copy dist/ -> mods/<name>_<version>/
factorio-rs install --open # install, then launch Factorio
factorio-rs package # release profile and zip at project root

Zip 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.