Your first mod
A mod is the one unit of content: a directory the engine discovers, holding a manifest that declares what the mod publishes and a WebAssembly component that runs it. See the modding hub for the whole picture. This page takes you to a mod under your own author name that puts one marker in the world and greets every player who joins, in the server log.
What you need
Section titled “What you need”- The game, installed and able to host a session: Install and run.
ironlark-cliand a Rust toolchain: The command-line tool.
The mod on this page is called greeter and its author is called you. Put
your own name where you stands; the rest works unchanged.
Build it
Section titled “Build it”-
Create the mod.
Content lives in your install’s
assets/workshop/, exactly two levels deep: author, then mod. Go there and create the mod:Terminal window cd ~\.ironlark\assets\workshopironlark-cli mod create you:greeterTerminal window cd ~/.ironlark/assets/workshopironlark-cli mod create you:greeterThe two directory names it creates are the mod’s identity,
you:greeter. A manifest cannot claim a name, because where the files sit cannot be forged. Names are lowercase ASCII letters and digits, starting with a letter or a digit, with single-between words.Directoryworkshop
Directoryyou/ your author name
Directorygreeter/ the mod: together the two names are
you:greeter- mod.toml what the mod declares
- Cargo.toml one workspace for the mod’s code
Directory.cargo
- config.toml pins the build target
Directoryserver
- Cargo.toml
Directorysrc
- lib.rs the code
Every file is already correct: the mod builds and loads as it is, with a server half that logs one line when it starts. The next two steps give it something to do. Run every command from here on inside
you/greeter. -
Declare what the mod publishes, in
mod.toml.The manifest is the mod’s public declaration: its version, what it puts in the world, and which events it wants to hear. Replace its contents with:
[mod]version = "0.1.0"description = "A marker in the world, and a greeting for every joiner."[[declares.archetype]]id = "marker"shape = { kind = "box", size = [1.4, 2.4, 0.2] }material = { color = "#26bfe6" }[declares.server]hooks = ["on_join"]Two declarations, and each earns its place:
[[declares.archetype]]publishes a kind of thing that can exist in the world. This one is a host-builtshape: a box with a colour, so no model file is needed; mesh and collider come from the same numbers. Its full name isyou:greeter/archetype/marker, and your own code spawns it by the baremarker.[declares.server]lists the events your server code is woken for. A hook you do not declare never fires, and the build refuses a hook function the manifest does not list.initis the exception: it always runs, so it needs no line.
-
Write the code, in
server/src/lib.rs.Replace the file with:
mod protocol {ironlark::declares!("../mod.toml");}use ironlark::server::prelude::*;struct Greeter;#[ironlark::hooks("../mod.toml")]impl ServerMod for Greeter {async fn init() {log::info!("greeter: init");let at = SpawnPoint {position: Vec3::new(0.0, 1.2, 4.0),yaw: 0.0,};let marker = match Entity::spawn(protocol::archetype::Marker, at).await {Ok(marker) => marker,Err(e) => {log::error!("greeter: spawn failed: {e}");return;}};if let Err(e) = marker.set_id("marker").await {log::error!("greeter: set-id failed: {e}");return;}log::info!("greeter: spawned the marker");}async fn on_join(_ctx: Context, player: Player) {log::info!("greeter: welcome, {player}");}}ironlark::export_server!(Greeter);Reading it top to bottom:
ironlark::declares!("../mod.toml")reads your manifest while the crate compiles and creates one Rust item per declared archetype:protocol::archetype::Markerhere. Spawning by a checked item instead of a string means a typo is a compile error, and renaming the archetype in the manifest breaks the build instead of the session. The path is relative to the crate,server/, hence../.impl ServerMod for Greeteris the whole surface: every hook has a default, so you write only the ones you want.initruns once when the mod loads; it spawns the marker withEntity::spawnand gives it a lasting address withset_id, so other mods, and a reload, can find it.#[ironlark::hooks("../mod.toml")]ties the code to the manifest: the hooks you declared in step 2 are checked against the functions you wrote, while it compiles.on_joinreceives the joiner as aPlayer. Logging{player}printsplayer#<n>, the number this participation is addressed by. It fires because step 2 declared it.ironlark::export_server!(Greeter)makes the type the component’s server half. Without it the file is a library nobody calls.
-
Build it.
Terminal window ironlark-cli mod buildIt compiles the server half and places the component beside
mod.toml, where the engine opens it, then prints where:/home/you/.ironlark/assets/workshop/you/greeter/greeter_server.wasmRebuild with this same command after every change. The engine always loads the component beside
mod.toml, andmod buildis what keeps that copy current. -
Check it.
Terminal window ironlark-cli mod checkyou:greeter is readyThis runs the formatter and the linter for the target the game loads, and the same checks of your code against
mod.toml, without building. Run it before you share the mod. -
Let the session pick it up.
Installed is enabled, by default: when the server configuration has no
[session] modslist, nobody has curated the install and everything underworkshop/runs, your mod included, with nothing to switch on.A curated install lists what runs, in
config/server.tomlbeside the install. If yours has such a list, add your mod to it:[session]mods = ["you:greeter"]How that list works (order, dependencies, what an empty list means) is Enabled mods.
-
Run it and read the log.
Host a session. The hosting instance writes its log to
logs/host.logunder the directory it runs in. Three lines tell you everything worked, in this order:server-mod loaded: you:greetergreeter: initgreeter: spawned the markerThe first is the engine reporting your component loaded; the other two are your own
initspeaking. Every line a mod writes is attributed with its identity, so a session full of mods stays readable. Then join, and your greeting appears with the joiner’s participation number in place of<n>:greeter: welcome, player#<n>In the world itself, the marker stands as a coloured box a few steps ahead of the default spawn.
If instead the log says your mod “has a server realm that is not built: no component at …”, the engine found your manifest but not your component: run
ironlark-cli mod buildin the mod’s directory and start again.
Where to go next
Section titled “Where to go next”Your mod declares, spawns and listens: every mod is a variation on those three moves.
- Signals: say things other mods, and clients, can hear, and hear theirs.
- Entities: move the marker, find it again, own it properly.
- Declarations: everything a manifest can say.
- The ironlark-cli reference: every command and option.