Make an extension
An extension adds something to the game a campaign plays, whatever its system: commands the master calls, fields and counters on the sheet, lines in the master’s instructions, widgets on the dashboard. Our weather and lockpicking are extensions. It is data (extension.yaml) and code in TypeScript.
An extension is an npm package. Its name without the scope is the name its commands start with: @you/tide-clock gives tide-clock and tide-clock-advance.
You need Node 24, npm, and RPG Engine (npm install -g rpg-engine). The engine does not rule: an extension keeps a count or a state the master would get wrong, and leaves the judgement to the master.
Steps
-
Make the extension. In a terminal, from the folder where you want it:
rpg package new "Tide Clock" --kind extensionYou should see:
Made the extension Tide Clock in ...\tide-clock: tide-clock on npm, its commands tide-clock and tide-clock-advance. 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 "...\tide-clock" adds it to the campaign, its code from the dist/ the build made.Give a title, as here, or an npm name, as
@me/tide-clock. The folder must be empty or new;--folder <path>puts it somewhere else. It holds a small extension that works, a clock of six steps the master fills as a danger draws near:File What it is extension.yamlits title, its line for the master ( about), its icon and its widget; the other keys in commentsinstructions/play.mdlines added to the master’s instructions while playing src/index.tsits code: the commands tide-clockandtide-clock-advance, and the widget’s hooktest/extension.test.tsits tests, on the engine’s test kit package.jsonits npm name, version, and rpg-engine: {kind: extension, 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 tide-clock npm install npm testnpm testbuildsdist/and runs the tests:Tests 2 passed (2). They run the commands in a campaign made for the test (testCampaign) and read the widget as the dashboard shows it (campaign.widgets). -
Make it yours. Change
extension.yaml,instructions/,src/and the tests with them; runnpm testafter each change. The code reaches the game only throughgame: it reads pages and settings, rolls, asks the player, writes fields and counters, and keeps its own state. It uses the engine’s dice and time, neverMath.randomorDate. Beyond the clock it can act as time passes or after a roll, show more widgets, and draw in the page with a page module: what code can do. -
Try it in a campaign. Make one for testing and install the extension from its folder:
rpg init clock-test --system free cd clock-test rpg package install "<path of tide-clock>"A window asks you to allow it, as for any package that is not ours: its code runs on your computer. Then:
Installed tide-clock 0.1.0, not verified: at the player's risk, and the campaign uses it: a clock of six steps the master fills as a danger draws near, shown beside the rolls. Its commands: tide-clock, tide-clock-advance. Its parts of your instructions are given when they apply: play.Run its commands by hand:
rpg tide-clock-advance --by 2The clock is at 2 of 6.Then play a scene with your AI app in that folder: the master reads
aboutand the instructions, calls the commands, and the widget shows on the dashboard, in a card beside the rolls. -
Publish it on npm. Choose a licence (
LICENSE.mdandlicenseinpackage.json), give any credit its text needs inattributioninextension.yaml, writedescriptioninpackage.json, then:npm publish --access public--access publicis needed only for a scoped name (@you/...). Keep the keywordrpg-engine-packageinpackage.json:rpg package availableand the dashboard’s Packages page list the npm packages that have it. If it is made for one game system, say so withneeds: {system: <name>}inextension.yamland"system": "<name>"underrpg-engineinpackage.json.
What a player gets
A player installs your extension from the dashboard’s Packages page, or by its npm name: rpg package install @you/tide-clock, or rpg package install npm:tide-clock 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 on the computer and adds it to that campaign alone; another campaign adds it with its own package install.
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 and inrpg package available, and the master is told of it at the start of a session. rpg-engine.apiinpackage.jsonis the version of the package API the extension 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 extension.devDependenciesnames the RPG Engine your tests run on. Raise it to test with a newer engine.
When something fails
Unknown command "tide-clock": the campaign does not use the extension. Install it from that campaign’s folder (step 4).There is no campaign here: runpackage installfrom a campaign folder.... is no npm package name, or... cannot name an extension: the npm name you gave does not work.package newtakes a title, which it turns into a name, or an npm name in lowercase such astide-clock.roll is one of the engine's commands: an extension’s commands start with its name, so it cannot take the name of one of the engine’s. Pick another title.... is not empty:package newneeds an empty or new folder.- A widget shows nothing:
campaign.widgets()in a test gives itsproblem, the reason. - The master does not see a change: rebuild, install again, and start a new chat.
To take it out of a campaign: rpg package remove tide-clock. To take it off the computer: rpg package uninstall tide-clock.
Reference
- Every key of
extension.yaml, its code, widgets, words and installing: extensions.md. - The fields, counters and recipes an extension adds work as a campaign’s: game-systems.md, What a campaign adds.
- The test kit,
rpg-engine/testing: extensions.md, Tests. - Extensions that work in full: weather, lockpicking.