Make a game system
A game system is the data of one game: the fields of its character sheet, the formulas that work out its numbers, its counters and rests, its pages (creatures, items, classes) and its rules text, which the master looks up. A campaign plays one system. Where data is not enough, the system brings code too, in TypeScript: commands the master calls and widgets on the dashboard.
A system is an npm package named system-<name>, or @<you>/system-<name>. Campaigns know it by <name>: system-starforged is played as starforged, and its commands start with that name.
You need Node 24, npm, and RPG Engine (npm install -g rpg-engine). The engine does not rule: it keeps the sheet and the numbers, and the master applies the rules text. Put a mechanic in data or code only when the master gets that count wrong.
Steps
-
Make the system. In a terminal, from the folder where you want it:
rpg package new "Star Test" --kind systemYou should see:
Made the game system Star Test in ...\system-star-test: system-star-test on npm, played as star-test. Next, in that folder: npm install, then npm test, which builds it and runs its tests. Then, in a campaign's folder, rpg package install "...\system-star-test" puts it on this computer for a new campaign: its setup offers it, or rpg init <folder> --system star-test makes one that plays it.Give a title, as here, or an npm name, as
@me/system-starforged. The folder must be empty or new;--folder <path>puts it somewhere else. It holds a small game that works:File What it is system.yamlthe fields, formulas, counters, rests and sheet; the other keys in comments rules/Basics.mda chapter of rules, which the master finds with rpg rulesworld/creatures/Wolf.mda page of the system, which every campaign that plays it sees instructions/play.mdlines added to the master’s instructions while playing src/index.tsits code: a command, star-test-roll, that rolls 2d6 plus an abilitytest/system.test.tsits tests, on the engine’s test kit package.jsonits npm name, version, and rpg-engine: {kind: system, api}README.md,LICENSE.md,.github/workflows/ci.ymlto fill in; CI runs the tests on Linux, Windows and macOS tsconfig.json,vitest.config.ts,.gitignorethe build’s and the tests’ settings, as they are -
Build and test it, in its folder:
cd system-star-test npm install npm testnpm testbuildsdist/and runs the tests:Tests 2 passed (2). The first test checks the data as the engine reads it (systemChecks): every page reads, every field is declared and fits its kind, every rule named exists. The second plays the roll in a campaign made for the test (testCampaign). -
Make it your game. Change
system.yaml,rules/,world/andinstructions/, and the tests with them; runnpm testafter each change. Start from data: the reference lists every key ofsystem.yaml. Then add insrc/index.tswhat data cannot say: commands, hooks on the game’s events, widgets on the dashboard, and in a page module the drawing of a group of the sheet (what code can do). -
Install it on your computer. Installing needs a campaign folder, so make one in free play to install from:
rpg init test-campaign --system free cd test-campaign rpg package install "<path of system-star-test>"A window asks you to allow it, as for any package that is not ours: its code runs on your computer. Then:
Installed the game system star-test 0.1.0, Star Test, not verified: at the player's risk. It is for a new campaign, chosen in its setup: this one plays free. Its code runs from the next start of the game's server.The system is now on this computer for every campaign:
rpg package listnames it underGame systems. -
Play it. A campaign still in setup can switch to it, as this one is:
rpg config system star-testIt answers
system: star-test, Star Test (system-star-test 0.1.0), then lists the settings still to agree with the player: that list is for the master, not an error. Or make a new campaign that plays it:rpg init <folder> --system star-test. Then try it by hand:rpg write Kira --type character --set role=pc --set body=2 --set mind=1 rpg show Kira rpg star-test-roll Kira bodyKira rolls body: 2d6+2 = 7 [1, 4] + 2, a success.Your dice will differ.
writealso says which fields of the sheet Kira still lacks, hereconcept: a note, not an error. Then play a scene with your AI app in that folder: it is the only real test of the rules text and the instructions. -
Publish it on npm. Choose a licence (
LICENSE.mdandlicenseinpackage.json), give the credit its text needs inattributioninsystem.yaml, writedescriptioninpackage.json, then:npm publish --access public--access publicis needed only for a scoped name (@you/...). Keep the keywordrpg-engine-packageinpackage.json: the dashboard’s Packages page lists the npm packages that have it.
What a player gets
A player installs your system from the dashboard’s Packages page, or by its npm name: rpg package install @you/system-star-test, or rpg package install npm:system-star-test for a name without a scope (a name alone means one of RPG Engine’s own). A window asks them to allow it first, since its code runs on their computer. It installs for every campaign on the computer, and a new campaign’s setup offers it. A campaign that already plays another system keeps it.
Update it
- After a change, run
npm test, thenrpg package install "<its folder>"again in your campaign. The command line uses the new code at once. An AI app’s MCP server keeps the code it started with: start a new chat, or reconnect the server. - To release, raise
versioninpackage.jsonandnpm publish. Players see the update in the Packages page. rpg-engine.apiinpackage.jsonis the version of the package API the system is written for. Raise it only when you use a key or a function that a newer API added: what each API number added. An older engine then asks its player to update, instead of misreading the system.devDependenciesnames the RPG Engine your tests run on. Raise it to test with a newer engine.
When something fails
"star-test" is not an installed system: install it first (step 4).There is no campaign here: runpackage installfrom a campaign folder (step 4).There is already a game system named ..., frompackage neworpackage install: another system on this computer, or one of RPG Engine’s own, is played by the same name. Pick another title or name, or uninstall the other one. Titles may repeat; names may not.... is no npm package nameorA game system's npm name ends in system- and its name: the npm name you gave does not work.package newtakes a title, which it turns into a name, or an npm name such assystem-starforged.... is not empty:package newneeds an empty or new folder.- A test of
systemChecksfails: the list it gives names the page, field or rule at fault. - The master does not see a change: rebuild, install again, and start a new chat.
To take it off the computer: rpg package uninstall star-test, from a campaign that does not play it.
Reference
- Every key of
system.yaml, the formulas, pages, rules, words and instructions: game-systems.md. - A system’s code (commands, hooks, widgets, the page module) has the same contract as an extension’s: extensions.md, Code.
- The test kit,
rpg-engine/testing: extensions.md, Tests. - A system that works in full, with code: the 5e.