Roves
Integrations

Mods and DLC

Let players add official DLC and community mods to your game, and build them with the Roves tools.

Edit on GitHub

Requirements

Mods and DLC need the Roves player v0.9.2 or later and @drincs/roves-cli 0.6 or later (also inside the GitHub Action and Packmaster), plus @drincs/roves-api 0.11 or later (0.12 for mods.isAvailable()) in your game. They work on desktop (Windows, macOS, Linux), not in Android and iOS builds.

Roves can load extra content next to your game: DLC that you publish yourself, and mods made by your players. Each one has an id, a name, a description, a cover image and its own version, and says which versions of your game it works with. Your game lists them through roves-api and lets the player turn them on and off.

DLC and mods

DLCMod
Made byyouanyone
Where it livesdlc/ next to the gamemods/ next to the game, or the player's profile folder
Shipped in your packageyes, with roves bundle --dlcno, the player adds it
File name<id>.rovesmod<id>-<version>.rovesmod
Listed whenit is one of your game's official DLCalways (unless turned off)
Enabled by defaultyesyes
Steam ownership checkoptional (steamAppId)no
Turned off by --no-modsnoyes

Only your official DLC load. When you pack a DLC in your game's project, Roves records it (its id, version and a fingerprint of the exact file) in your project, and every package you build carries that list. The player shows a DLC only when its file matches an entry, and ignores any other DLC. A DLC that someone else built, or that was changed, is never started by your game as you shipped it. Anyone else can only make mods.

If the same mod or DLC is installed more than once, in different versions, the player uses the most recent version.

The player's profile folder is the usual place for mods, because the game's own folder is often read-only (Program Files, a Steam library).

What a mod can do

A mod can do one or both of these:

  • Replace or add files. Put them in an overrides/ folder, at the same paths they have in your game. When the game asks for a file, the player looks in the enabled mods first, in their load order, and then in your game. A mod that ships overrides/assets/backgrounds/park.png replaces your park background; a new path adds a file. Images, sounds, translations, story files and JSON data can be changed this way without any code, and without your game doing anything special.
  • Run code. A mod's main is a JavaScript module. Your game decides when mods run and what they can reach: it calls mods.loadAll(api), and every enabled mod receives the api object you pass. Expose only what you want modders to use, for example "add a story label", "add a character" or "add a minigame".
import { mods } from "@drincs/roves-api";

// At startup, after your own content is registered:
await mods.loadAll({
  addLabel: (label) => { /* ... */ },
  addCharacter: (character) => { /* ... */ },
});
// The mod's main module
import { defineMod } from "@drincs/roves-api";

export default defineMod({
  activate(api) {
    api.addLabel(myNewEnding);
  },
});

Mod code runs with the same rights as your game's own code, like mods in most engines. The player shows a warning the first time a mod with code is enabled.

package.json

A mod or DLC is described by an ordinary package.json, the same file you already use for any JavaScript project. Roves reads the standard fields, plus a small roves section:

{
  "name": "@author/new-ending",
  "displayName": "New ending",
  "description": "An extra ending after chapter 5.",
  "version": "1.2.0",
  "author": "Author",
  "type": "module",
  "main": "dist/index.js",
  "files": ["dist", "overrides", "cover.png"],
  "peerDependencies": {
    "@drincs/pixi-vn": "^1.3.0"
  },
  "dependencies": {
    "lodash-es": "^4.17.21"
  },
  "roves": {
    "kind": "mod",
    "game": { "name": "mygame", "version": "^1.4.0" },
    "mods": { "@other/characters": "^2.0.0" }
  }
}
FieldMeaning
nameThe mod's id: unique and stable. A scoped name (@author/...) avoids clashes.
displayNameThe name shown to players; name when missing.
description, authorShown to players.
versionThe mod's own version, in semver form.
mainThe JavaScript module to run. Optional: a mod without it only replaces or adds files.
filesWhat goes into the packed mod, as for npm pack.
peerDependenciesLibraries the mod reuses from the game (see Libraries).
dependenciesLibraries the mod brings, built into its own code.
roves.kind"mod" (the default) or "dlc".
roves.gameThe game the mod is for: the name of the game's own package.json and a version range.
roves.modsOther mods this one needs, with version ranges.
roves.steamAppIdDLC only: shown only when Steam reports that the player owns it.

All versions in peerDependencies, dependencies, roves.game and roves.mods are npm-style ranges: ^1.4.0 (any 1.x from 1.4.0), ~1.4.0 (1.4.x), >=1.4.0 <3, 1.x.

A mod whose game range, required mods or shared libraries don't match is listed as incompatible, with the reason, and is never loaded.

Cover image

There is no field for the image: put a file named cover at the root of the mod (cover.png, cover.jpg or cover.webp) and it becomes the mod's image. A 16

image (for example 1280×720) fits most mod screens.

Libraries

A mod can reuse libraries that your game already contains, or bring its own.

  • Brought by the mod (dependencies): built into the mod's own code. Fine for small helpers such as lodash. The packed mod records the exact version that was installed when it was packed.
  • Shared by the game (peerDependencies): the mod uses the game's own copy, with the same state. This is required for libraries that break when a page loads them twice: they keep global state or registries, own the one WebGL or audio context, or compare objects with instanceof. With two copies of pixi.js, for example, the game stops working.

Libraries to always share: pixi.js and @pixi/*, @drincs/pixi-vn, phaser, three, @babylonjs/core, excalibur, kaplay/kaboom, matter-js, planck, tone, howler, @pixi/sound, motion/framer-motion, gsap, and the UI framework (react/react-dom, vue, solid-js).

Sharing a library from your game

You decide how your game is built: Roves does not change your build. To share a library, give it its own entry chunk named after the package, without its scope (@drincs/pixi-vn becomes pixi-vn), and keep its public API with preserveEntrySignatures: "strict":

// vite.config.js
export default {
  build: {
    rollupOptions: {
      input: { index: "index.html", "pixi.js": "pixi.js", "pixi-vn": "@drincs/pixi-vn", tone: "tone" },
      preserveEntrySignatures: "strict",
    },
  },
};

Your game still loads a single copy: its own code imports from those chunks. Don't use output.manualChunks for this. A manual chunk keeps one copy inside your game, but exports only a few internal, minified names instead of the library's API, so a mod can't use it.

List each shared library in your dependencies, even one you only get through another package (pixi.js, tone and motion with @drincs/pixi-vn): Roves only looks at dependencies. It reads the versions from node_modules, or from package-lock.json when you package a dist/ built in another job. The visual-novel-template shares pixi.js, @drincs/pixi-vn, tone and motion this way.

To keep the download smaller, the entry can point at your own file that re-exports only what mods may use (the chunk keeps the same name, so it is still recognized):

// src/shared/pixi.ts
export { Assets, Container, Sprite, Texture } from "pixi.js";
// vite.config.js: input: { index: "index.html", "pixi.js": "src/shared/pixi.ts" }

A full entry ships the whole library (pixi.js 8: about 860 KB, 250 KB gzipped, against 470 KB / 130 KB when the game alone tree-shakes it); a reduced one ships only what it re-exports. The code is minified either way: only the exported names are kept.

When you package the game, roves bundle looks for a chunk named after each of your dependencies (assets/pixi.js-<hash>.js) and lists the ones it finds, with their versions, as libraries your game shares. It warns you about a library that should be shared but has no chunk, or was split with manualChunks.

Using a shared library from a mod

Declare the library in peerDependencies with the versions you support, keep it out of your mod's bundle, and point it at the game's copy, which the player serves at /__mods/_shared/<package>.js:

// vite.config.js of the mod
export default {
  build: {
    lib: { entry: "src/index.js", formats: ["es"], fileName: () => "index.js" },
    rollupOptions: {
      external: ["pixi.js", "@drincs/pixi-vn"],
      output: {
        paths: {
          "pixi.js": "/__mods/_shared/pixi.js.js",
          "@drincs/pixi-vn": "/__mods/_shared/@drincs/pixi-vn.js",
        },
      },
    },
  },
};

Your code keeps importing pixi.js as usual, and gets the very objects the game uses. roves mod init --game lists what the game shares, and roves mod check tells you when your range doesn't match the game's version. Both lists can be read through roves-api, so a mod manager screen can show what each mod adds.

The roves-api mods module

CallWhat it does
mods.isAvailable()true when this device handles DLC and mods (the desktop player, v0.9.2 or newer). Show your DLC and mods screen only then: it is false in a browser and on mobile.
mods.isSupported()false when the game was packaged with --no-mods (DLC still work).
mods.list()Every DLC and mod found: id (name), kind, display name, description, cover image URL, version, author, enabled, compatible (and why not), required mods, shared and bundled libraries.
mods.setEnabled(id, enabled)Turns a DLC or mod on or off.
mods.setOrder(ids)Sets the load order: a later mod wins when two replace the same file.
mods.loadAll(api)Runs the main module of every enabled, compatible mod, in load order.
relaunch()Restarts the game (from @drincs/roves-api/process).

The enabled list and the order are saved in the player's profile. Changes take effect the next time the game starts, so a mod screen usually ends with a "Restart to apply" button that calls relaunch().

Packaging your game

Mods are allowed by default. To turn them off, pass --no-mods, or set "roves": { "mods": false } in your game's package.json:

roves bundle -c dist --no-mods

To ship DLC inside your package, point roves bundle at each DLC folder (or at its .rovesmod file):

roves bundle -c dist --dlc ./dlc/chapter-6

Mods are checked against the name and version of your game's package.json. roves bundle finds it in the folders above your build (dist/); pass --project-dir when it is somewhere else.

A mod kit for your modders (the TypeScript types of the api object you pass to mods.loadAll and the libraries your game shares) is planned; until then, publish the types yourself.

Making a mod

The quickest start is roves mod create. It asks what you are making (a mod, or a DLC if you are the game's developer), where the game is, the name, id, description and author, and which of the game's shared libraries you will use. It then creates a TypeScript project already set up:

  • the build (tsup), the linter (Biome) and the tests (Vitest);
  • a placeholder cover.png, an overrides/ folder and a starter src/index.ts;
  • npm start to run the game with your mod, and npm run pack to pack it;
  • for mods, a GitHub workflow that attaches the .rovesmod to a release.

For a mod, point it at the unzipped game folder (or the .app). It reads which libraries the game shares and sets them up so your mod uses the game's own copies.

roves mod create

The commands below are what the project's scripts call; you can also use them by hand:

roves mod init --game "C:/Games/MyGame"   # adds the roves section to an existing project
roves mod dev --game "C:/Games/MyGame"
roves mod check --game "C:/Games/MyGame"
roves mod pack                            # writes author-new-ending-1.2.0.rovesmod (a DLC: author-chapter-6.rovesmod)
  • roves mod init creates the mod for the game you point it at (the unzipped game folder, or the .app on macOS): roves.game gets the game's name and ^ its version. Add your cover.png yourself. In an existing project it only adds the roves section to your package.json; without a copy of the game, use --game-name.
  • roves mod dev starts the game with your mod folder loaded straight from disk and already enabled, without packing it. Run your own build in watch mode next to it (for example vite build --watch); replaced files are read again on every request, and the game restarts when your main module changes. Errors from your mod appear in the console with its id.
  • roves mod check reports what would make the mod incompatible with that copy of the game, before you publish.
  • roves mod pack checks package.json and writes a single .rovesmod file with the files npm pack would take (those in files, plus package.json and the cover; never node_modules), and records the exact versions of your dependencies. Players drop it in the mods/ folder; there is nothing to unpack.

Making a DLC

DLC are made the same way, with "roves": { "kind": "dlc" }, from your game's project (for example in a dlc-src/chapter-6/ folder next to your game's package.json). roves mod create asks for your game's source project and creates the DLC there, with npm run game:package to package the game for npm start:

  • roves mod dev loads a DLC folder as it is, so you can work on it.
  • roves mod pack writes <id>.rovesmod (no version in the name) and records that DLC version in roves-dlc.json, next to your game's package.json. Keep that file in your repository: older versions stay listed, so players who still have them keep them working. If your DLC folder is not inside the game's project, pass --project-dir <game project>.
  • roves bundle copies the list into the package. roves bundle --dlc packs a DLC folder (or takes a recorded .rovesmod) and ships it in the dlc/ folder next to the game.
  • A DLC sold separately (for example a Steam DLC with its own steamAppId) is installed in the same dlc/ folder. It must be recorded before you build the game version that should recognize it: a new DLC, or a new version of one, needs a game update that includes it.

Packmaster

Packmaster has a Game / Mods & DLC switch at the top. On the game side, the advanced settings have Allow mods, the list of official DLC to ship and your game's project folder. The Mods & DLC screen creates a new mod or DLC project, opens an existing one (name, version, cover), checks it against a packaged game, packs the .rovesmod and starts the game with it for a quick try.

Not covered yet

  • Mods on Android and iOS.
  • Steam Workshop: subscribing to mods from Steam is a natural next step, but isn't planned for the first release.

On this page