Type checking
The game transpiles TypeScript without checking it. tsc is the only type check, and it runs on your machine.
From a mod, skin or map-script folder that holds a copy of modding.d.ts:
npx tsc --noEmit --strict --target es2022 --lib es2022 --module esnext --moduleResolution bundler main.ts
Use skin.ts or script.ts instead of main.ts for a skin or a map script. A tsconfig.json with the same options does the same, and lets your editor use them: see A first mod.
Inside the repository you do not copy anything. The file content/mods/sdk/modding.d.ts is the SDK, and examples point at it with /// <reference path="../../../mods/sdk/modding.d.ts" />. The repository's own TypeScript runs the check:
node apps/web/node_modules/typescript/bin/tsc --noEmit --strict --target es2022 --lib es2022 --module esnext --moduleResolution bundler content/examples/mods/hello-hud/main.ts
cargo test -p modding --test sdk runs examples_type_check, which checks every mod of content/mods/ and every example mod against the committed SDK. It is skipped without Node and apps/web/node_modules, unless PVNG_REQUIRE_TSC is set.
The reference line has no effect at run time: the game ignores it. Types describe the API but do not enforce it. The game's own checks, in Rust, are the real ones: out-of-range values, unknown fields, budgets.
Installing
| How | For | Notes |
|---|---|---|
| Copy the folder | A mod, a skin | Into data\mods or data\skins. Then Reload on the Mods page (a mod), or start a map (a skin). |
Install… on the Mods page, or drop a .pvmod on the window |
A mod | Reads a package, checks it, installs it into data\mods\<id>. |
| Import… on the Skins page | A skin | Installs a .zip as a new folder. It never replaces a skin. |
Open a .pvmod with the game |
A mod | The file association starts the game or hands the file to the running one. The mod is installed switched off, because it is code: the player turns it on from the Mods page. |
| The catalogue | A mod, a skin | A new mod from the catalogue also starts switched off. See Submit to the catalogue. |
Installing a .pvmod runs the mod's top-level code once, in a throwaway engine with the usual budgets, only to read the declaration. Nothing else runs. The mod is refused, with a message that begins invalid mod package: or the mod does not load:, in these cases:
- the package breaks a rule of the format (
.pvmod); - the game's own mods folder already holds that id:
the game's own folder X already holds the modid; uninstall or edit it instead; - the folder
data\mods\<id>holds another mod:the folder X holds another mod (id); rename it first.
Installing a mod with an id that is already installed replaces it. Uninstalling moves the folder aside (.trash-<id>-…) and deletes it. The mod's storage file stays.
Install, uninstall and reload are refused during a play.
Reload and hot reload
There is no hot reload. The SDK declares ctx.hot (data, save, dispose) and ctx.off, and the engine supports hot reloading, but the game never asks it to reload a changed file, and it runs no file watcher. Do not build on ctx.hot: nothing calls its callbacks.
What you have instead:
| Kind | Edit loop |
|---|---|
| Mod | Edit, press Reload on the Mods page, play. Reload restarts the mod host: every mod loads again. Transpiled scripts are cached in data\mod-cache. |
| Skin | Edit, save, start a map. skin.ts is read again at every map launch. Use Customize skin to see it on a demo chart. |
| Map script | Edit, save, start the map. It is read again at every launch. |
A mod keeps no state across a reload except its storage file. Save what must survive with storage.set.
The log
| Where you write | Where it appears |
|---|---|
log.info(text), log.warn(text) |
The Messages list under the mod on the Mods page, with the level info or warning. Lines are cut at 1024 characters; the queue holds 256 messages and drops the rest. |
| An exception, a refusal, a budget overrun | The same list, with the level error. |
console.log and its siblings |
The game's standard error. A normal launch has no console, so you see nothing. Use log.*. |
| A crash of the game | prism-crash.log in the data folder, plus a report there. |
A diagnostic run (see the command line) keeps its console and prints what the game would show. Run it from a terminal.
Exporting
| Of | How | Result |
|---|---|---|
| A mod | Export on the Mods page | <id>-<version>.pvmod in a folder you choose. See A first mod and .pvmod. |
| A skin | Export on the Skins page | <id>.zip. See Skin package. |
| A theme | Zip the folder | See Themes. |
Hidden entries are left out. A mod export also leaves out node_modules.
Tests over the real engine
With a checkout of the repository you can load a script through the real engine, with no window, and assert what it does. The pages of this documentation do it for their own examples (crates/modding/tests/docs_examples_start.rs); crates/modding/tests/host.rs and the files beside it are larger models.
let mut options = ModHostOptions::new(&mods_dir); // a folder holding your mod folders
options.pinning = CorePinning::Disabled; // do not pin a core in a test
let host = ModHost::start(options)?;
assert!(host.wait_ready(Duration::from_secs(10))); // every mod loaded
let status = host.status(); // state, name, version of each mod
assert_eq!(status.get("hello-hud").unwrap().state, ModState::Active);
host.send(GameEvent::SongStart(song_start)); // what the game sends
host.wait_idle(Duration::from_secs(10)); // the queue is handled
let scene = host.scene(); // what the mods drew
assert!(scene.node("hello-hud", "combo").is_some());
For a skin set options.skin to a skin::Package and call host.prepare_play(context, patches, chart), which returns the playfield the skin and the map script described, as the game would draw it. Run one file with cargo test -p modding --test docs_examples_start.
The command line
The game is prism.exe. A normal launch takes no argument. Files given to it are opened as a double-click would: .osr, .pvreplay, .pvmod, .osk, .osz, .qp and .pvplaylist, and links of the form prism://map/<hash>.
| Flag | What it does |
|---|---|
--safe-mode |
Starts with only the game's own mods, the default skin and theme, and no map script. Nothing is saved. Holding Shift while the game starts does the same, and the game offers it after two starts that never reached the menus. Use it to tell your mod from the game. |
--skin <id> |
The skin a diagnostic run draws. <id> must be a valid skin folder name: --skin X is not a skin folder name. |
--gpu-backend <auto|dx12|vulkan|gl> |
Chooses the graphics API. It beats PRISM_GPU_BACKEND, which beats the saved choice. A value that does not parse is reported and the next source is tried. |
--smoke-test |
A diagnostic run: starts the game, runs the skin and the map script of the selected map as at a real launch, checks the native draw and the overlay, and exits. It prints `PRISM_SMOKE skin: <id> |
--smoke-edit, --smoke-auto, --smoke-training, --smoke-watch |
Other diagnostic runs, one per feature: editing, Auto, training and watching a replay. |
--bench-gameplay <seconds> |
A benchmark of a play of 1 to 3600 seconds (more than 0). It runs the skin and the map script like a launch and prints PRISM_BENCH skin: … and PRISM_BENCH map script: …. |
--map <path|demo>, --start <ms> |
With --bench-gameplay: the chart to play (demo is the built-in one), and where to start in it. |
--bench-repeat <plays>, --bench-pause <seconds> |
An endurance run around the benchmark: several plays in a row, with a pause between. --bench-repeat needs --bench-gameplay. |
--bench-key-sounds, --bench-fullscreen |
With --bench-gameplay: play key sounds, and borderless fullscreen. |
--check-library, --scan-library [args] |
Diagnostics of the song library of the data folder: a check, and a scan. |
--write-ts-packages [dir] |
Writes the TypeScript packages and exits. See the packages. |
--crash-test <seh|abort> |
Hidden: dies the way a native crash does, to check crash reports. |
--after-update <pid> <token> |
Internal: the game restarts itself with it after an update. Never pass it. |
Every diagnostic run opens the data folder of the player's game unless you tell it otherwise. Always set PRISM_DATA_DIR to an empty, absolute, writable folder first:
$env:PRISM_DATA_DIR = "$env:TEMP\prism-scratch"
prism.exe --smoke-test --skin first-skin
Diagnostic runs print to the terminal, never open a message box, take no single-instance lock and use a throwaway web view profile. They end with an error code when a check failed.
Environment variables
| Variable | Effect |
|---|---|
PRISM_DATA_DIR |
The whole data folder. Must be an absolute path, not a drive root, writable; it is created if missing. A bad value refuses to start: it never falls back to the real data. A line data dir: … (PRISM_DATA_DIR) is printed. While it is set, the data folder cannot be moved from Settings. |
PRISM_MODS_DIR |
The player's mods root, instead of data\mods. |
PRISM_SKINS_DIR |
The player's skins root, instead of data\skins. |
PRISM_THEMES_DIR |
The player's themes root, instead of data\themes. |
PRISM_FONTS_DIR |
The fonts folder, instead of data\fonts. |
PRISM_GPU_BACKEND |
auto, dx12, vulkan or gl. Beaten by --gpu-backend. |
PRISM_CATALOG |
The address of the catalogue. https only, except for localhost; this variable also lets you name a plain http server. |
PRISM_UPDATE_FEED |
The address of the release list. It beats the player's setting. https only (http for the local machine). |
PRISM_ONLINE |
The game server's WebSocket address, instead of wss://prism.am/play. It beats the setting. |
PRISM_ACCOUNTS |
The accounts site, instead of https://prism.am. It beats the setting. |
PRISM_SCAN_THREADS |
The number of threads of a library scan: a positive integer, capped at 32. Other values are ignored. |
PRISM_DEV_URL |
For work on the game's interface: load its pages from this development server. |
PRISM_INTERFACE_DIR |
For work on the game's interface: load another built interface from this folder. |
An empty address variable means the default.
The TypeScript packages
prism.exe --write-ts-packages [dir] writes one TypeScript package per area of the game under dir, as @pvng/<name>: package.json and index.d.ts. They hold the wire types between the game and its interface (@pvng/online and @pvng/desktop among them), generated from the Rust types. With no dir the default is apps/web/packages of the sources, so pass a folder when you run an installed game. The command needs no data folder.
They are not the mod SDK: mods use modding.d.ts. Use the packages if you write an interface for the game's protocol.
Tools of the repository
| Tool | What it is for |
|---|---|
cargo run -p modding --example write_sdk |
Regenerates content/mods/sdk/modding.d.ts, modding.ts and theme.d.ts from the Rust contracts. The test committed_sdk_matches_the_rust_contracts fails when they are stale. |
prism.exe --check-theme [<folder>] |
The installed game's own theme check (no window, no data written): the game's themes and <folder> (a folder of theme folders, or one theme folder; absent: the player's themes folder), one line per problem, exit code 1 on any. The game also writes the problems of its last listing to <data>/themes/problems.txt. |
cargo run -p modding --example check_theme [-- <folder>] |
Checks theme folders the way the game does, and prints one line per problem: "<theme>": <file>: <where>: <reason>. Exit code 1 on any problem. With no argument it checks content/themes. |
cargo run --release -p modding --example script_bench -- --out <file> |
Times the script engine: loading, events, host calls, memory. --compare a.json b.json compares two files. Options: --reps, --events, --calls, --pin core|last|off, --isolated, --quick. |
tools/build.ps1 [-Release] |
Builds the game: cargo build --locked -p desktop. |
tools/launch.ps1 |
Runs target/release/prism.exe, building it first if it is missing. |
tools/bench-realistic.mjs --exe <prism.exe> |
Realistic benchmarks (dense charts, key sounds, the shipped HUD mods) in a fresh data folder each run. |
tools/osu-replay-dump.mjs |
Downloads the online replays of one osu! profile through the osu! API v2, with your credentials. |
tools/check-changelog.mjs |
Checks the player-facing changelogs. |
tools/package.ps1, promote.ps1, sign-release.ps1, build-installer.ps1, test-installer.ps1 |
Release work: zip, promotion to stable, signing, installer. Of no use to a mod author. |
Next
- Every rule behind the messages you will see: Concepts.
- Limits as one table: Limits.
- A message you do not understand: Troubleshooting.