Skip to content
Ironlark is in closed pre-alpha. Join the Discord for access.

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.

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.

  1. 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\workshop
    ironlark-cli mod create you:greeter

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

  2. 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-built shape: a box with a colour, so no model file is needed; mesh and collider come from the same numbers. Its full name is you:greeter/archetype/marker, and your own code spawns it by the bare marker.
    • [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. init is the exception: it always runs, so it needs no line.
  3. 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::Marker here. 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 Greeter is the whole surface: every hook has a default, so you write only the ones you want. init runs once when the mod loads; it spawns the marker with Entity::spawn and gives it a lasting address with set_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_join receives the joiner as a Player. Logging {player} prints player#<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.
  4. Build it.

    Terminal window
    ironlark-cli mod build

    It 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.wasm

    Rebuild with this same command after every change. The engine always loads the component beside mod.toml, and mod build is what keeps that copy current.

  5. Check it.

    Terminal window
    ironlark-cli mod check
    you:greeter is ready

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

  6. Let the session pick it up.

    Installed is enabled, by default: when the server configuration has no [session] mods list, nobody has curated the install and everything under workshop/ runs, your mod included, with nothing to switch on.

    A curated install lists what runs, in config/server.toml beside 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.

  7. Run it and read the log.

    Host a session. The hosting instance writes its log to logs/host.log under the directory it runs in. Three lines tell you everything worked, in this order:

    server-mod loaded: you:greeter
    greeter: init
    greeter: spawned the marker

    The first is the engine reporting your component loaded; the other two are your own init speaking. 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 build in the mod’s directory and start again.

Your mod declares, spawns and listens: every mod is a variation on those three moves.