For game developers¶
How to open a game system to mods. Every system follows the same steps, which keeps the API and these docs consistent.
1. Data first¶
Move the system's numbers and lists into a content kind:
- Add it to
S.KINDSandS.fieldsingame/content_schema.lua. - Add a doc entry for every field to
S.DOCS. - Add the base file to
game/data/content/base/. - List the file in
scripts/release_manifest.json. - Read it through
Content.list(kind).
Base rows keep their order and values, so level digests don't change.
game.brackets is the model: the ladder is difficulties.json, and the code
only reads rows.
2. Hooks for behaviour¶
Where a row chooses code, give it a hook field naming an entry in
game.hooks. Base behaviour registers there too, as game.car_perks does.
With nothing registered, the simulation skips the dispatch.
3. API entries¶
Add modder helpers to game/game/mod_api.lua, each with its doc and example.
4. Regenerate the reference¶
From game/: lua ../scripts/mod_api_docs.lua. mod_api_docs_test.lua
fails if a field or entry lacks a doc or API.md is stale.
5. Add an example¶
Put it in docs/modding/examples/. mod_examples_test.lua loads every example.
6. Update the guide and site¶
Update the matching page in docs/modding/guide/ and run
python3 scripts/docs_site.py build (strict: broken links fail).
Other conventions¶
| Topic | Rule |
|---|---|
| Player-facing text | Goes through game/game/text.lua. Add the English to game/data/content/base/text/en.json and draw T('menu.key'), with {name} tokens for live values. Schema fields marked text=true are translatable by row key automatically. |
| Tuning numbers | Stay in their modules. To expose one, list it in a system in game/game/balance.lua with a range and doc, and make sure the module calls Balance.apply before deriving anything (as game.economy and game.pursuit_balance do). |
| Mod art and sound | Load through game/game/mod_assets.lua. Positions are decided during content load; main.lua passes the list to Graphics.addSprites and Sound.register; Graphics.composeSprites pastes art into the atlas. CPU previews read data/sprite_atlas.json, so they don't show mod art. |
| Workshop | game/platform/steam.lua is the only module that loads LuaSteam and does nothing without it. game/platform/workshop.lua mounts each item's mod.zip at workshop/<item id>. Tests inject a fake with Steam.use(adapter) before Steam.start(). |