Your first mod
A panel in the overlay that says hello and graphs the frame time, built in C against the generated header and run in the Axiom Sandbox, which needs no game. It is the same path the Axiom repository's own overlay test mod takes.
Until the first release, the CLI and the launcher come from a build of the Axiom source, and the Sandbox's overlay window is macOS only. Everything below is what that build does today.
What you need
- A clang with the WebAssembly backend, and
wasm-ld. Apple's clang has no wasm backend; Homebrew'sllvmandllddo. axiom, the CLI, and the launcher.- surface.h, the header every mod compiles against.
Write the mod
A mod exports on_frame, which the host calls once a frame. This one opens a panel, puts a line of
text in it and pushes one value to a graph. The host keeps the panel and its history, so a frame
where nothing changed costs nothing.
"surface.h" #define LEN(s) (sizeof(s) - 1) __attribute__((export_name("on_frame"))) OnFrame() { AxiomUiOverlayPanelId panel; (axiom_ui_overlay_panel("Hello", LEN("Hello"), &panel) != 0) { /* No overlay on this backend: nothing to draw into. */ ; } axiom_ui_overlay_text(panel.index, panel.generation, "Drawn by a mod.", LEN("Drawn by a mod.")); axiom_ui_overlay_graph(panel.index, panel.generation, "Frame time (ms)", LEN("Frame time (ms)"), axiom_frame_delta() * 1000.0f, 120); }
There is no C library: strings cross as a pointer and a length, so LEN measures a literal at compile
time. Every call that can fail returns a status, 0 for success. See the guest ABI for how
each value crosses.
Say what it needs
The manifest sits beside the binary. It names the two capabilities the mod imports, and the game it is for, which is the Sandbox.
id = "io.github.yourname.hello" name = "Hello" version = "0.1.0" tier = "wasm" phase = "runtime" [capabilities] require = ["frame@1", "ui.overlay@1"] [targets] game = "axiom.sandbox" builds = ">=0.1.0"
Replace yourname with your GitHub login: a package is published into a namespace you hold, and
io.github.<login> is the one every account starts with. Every key is on
the manifest page.
Build it
The binary has to be called mod.wasm. It comes to a few hundred bytes, and its only imports are
the four calls it makes. axiom check reads the manifest and reports every fault at once. axiom build packages the directory into an .axpkg, refusing any file the format cannot hold rather than
leaving it out.
Publish it
A mod runs only signed, and the Sandbox runs mods from your library like any game does, so the way in is the registry. Publish it hidden: it stays out of every list and installs by its exact id.
axiom login opens the browser for one click of approval. axiom sign --key main, with no package,
registers the key with your account. Each of these is on the CLI reference.
Run it
Install checks the package against the registry's signed metadata and your signature, and asks before it installs. Then open the launcher, go to the Axiom Sandbox and press Launch. F8 opens and closes the overlay; closed, it shows only the mods' panels, in the top right.
A graph is drawn as its latest value rather than as a line, and the overlay window is macOS only. Buttons and settings do reach the mod, as events: see Events.