Functions
chart.getNotes
function chart.getNotes(input: void): ChartNotes;
Returns the notes of the chart about to be played, as four typed arrays plus a few numbers. It works only inside a chart.transform handler, and only in the mod the event was delivered to. Elsewhere it throws chart.getNotes is only available inside a `chart.transform` handler.
The notes are the 1x chart, before the music rate, after the transformations that ran earlier. count entries per array: startUs and endUs are little-endian Float64 values (read them with new Float64Array(notes.startUs.buffer, notes.startUs.byteOffset, notes.count)), column is one byte per note from 0, kind is one byte per note: 0 tap, 1 hold, 2 burst, 3 mine. endUs is 0 for a tap and a mine. keys is the column count, durationUs the end of the map, seed a random number drawn for this play and this mod, the seed of a reproducible shuffle. Times are microseconds.
ctx.on("chart.transform", (request) => {
if (request.id !== "stats") return;
const notes = chart.getNotes();
const holds = notes.kind.filter((kind) => kind === 1).length;
log.info(`${holds} holds in ${notes.count} notes on ${notes.keys} keys`);
});
A handler that never calls chart.setNotes leaves the chart untouched. See Transforming the chart.
chart.setNotes
function chart.setNotes(input: NoteSubmission): void;
Hands the game the full replacement for the chart. It works only inside the chart.transform handler of the mod that received the event, and the game delivers that event only for a modifier of kind chartTransform that the player switched on. Elsewhere it throws chart.setNotes is only available inside a `chart.transform` handler.
Give the same four arrays as chart.getNotes (Uint8Array, an ArrayBuffer or an array of bytes), with any note count up to 100000; notes may be in any order, the game sorts them by start time. The game validates the buffers and refuses the whole modification of the mod on the first problem, even when the script catches the exception and submits another buffer: the notes stay as they were and a notice is shown, the map is never corrupted. A run that is too slow or out of memory is dropped the same way. A play whose notes ended up different is unranked.
ctx.on("chart.transform", (request) => {
if (request.id !== "rotate") return;
const notes = chart.getNotes();
const column = notes.column.map((value) => (value + 1) % notes.keys);
chart.setNotes({ startUs: notes.startUs, endUs: notes.endUs, column, kind: notes.kind });
});
Errors you will see: 100001 notes exceed the limit of 100000, `column` holds 10 bytes, 12 expected for 12 notes, note 3: a tap or a mine has no end time, `endUs` must be 0 (got 500), note 3: kind 7 is not 0 (tap), 1 (hold), 2 (burst) or 3 (mine), note 3: column 5 is outside the 4 columns, note 3: two notes at 1000 us in column 1, note 3: starts at 900 us in column 1 before the note before it ends (1500 us), and note 3: … us is outside the map (… us).
gameplay.register
function gameplay.register(input: GameplayModifierDeclaration): void;
Declares a modifier the player switches on from the Mods tab. Only mods call it, and only from setup. The modifier is published as <modId>/<id>. kind says what the game does when it is on: auto, ghost, fullLn and noPause are native behaviors; chartTransform hands the chart to your script through the chart.transform event (see chart.getNotes and chart.setNotes); noteMask hands the drawing of the playfield (covers on the notes' region, a lift of the receptor line) to your script through the playfield.noteMask event (see playfield.setNoteMask). mirror, noLn and rankedFullLn are built into Prism and a mod cannot declare them; the old sudden, hidden and lift kinds are gone, those modifiers are noteMask mods.
group is one of assist, layout, longNotes, timing, difficulty, other; when absent the kind's own group applies. icon is one of 28 lucide names (MODIFIER_ICONS in modifiers.rs); when absent the kind's icon applies. conflictsWith lists up to 8 keys written <modId>/<id>: the Mods tab refuses to switch both on. A noteMask modifier declares its own sliders in params (at most 8; the other kinds take none, the game declares those of fullLn): each is { id, label, description, section, min, max, step, default, unit? } with an id of letters and digits starting with a letter, integer bounds within ±1000000, min < max, a step from 1 to max - min, a default inside the bounds and a unit of % or ms. A play whose notes a chartTransform script changed is unranked; a noteMask modifier only changes what is drawn and never unranks; the other native kinds keep their own rules.
| Limit | Value |
|---|---|
| Modifiers per mod | 8 |
id |
a-z, 0-9, -, 1 to 32 characters |
name |
1 to 32 characters |
description |
1 to 200 characters |
conflictsWith |
at most 8 keys |
gameplay.register({
id: "steady",
name: "Steady",
description: "The pause key and a lost window focus do nothing during the play.",
kind: "noPause",
group: "other",
icon: "shield",
});
Errors you will see: Mirror is built into Prism: a mod cannot declare it (also No long notes is built into Prism: … and Full long notes is built into Prism: …), modifier id is registered twice, a mod registers at most 8 gameplay modifiers, modifier group "x" is not one of assist, layout, longNotes, timing, difficulty, other, modifier icon "x" is not an allowed icon, conflict "x" is not a <modId>/<id> key. See Gameplay modifiers.
judgements.register
function judgements.register(input: JudgementSetDefinition): void;
Adds a judgement set the player can pick in the settings: a list of tiers (Perfect, Great, …, then the Miss) with their timing windows and weights. Only mods call it, and only from setup. The set is published as <modId>/<id>, at most 97 characters.
tiers is a pure function from the set's parameter values to the tiers. The host calls it for every combination of parameters while the mods load (up to 4096 combinations per set and 1 second for all sets together); a set with more combinations resolves the rest on first use. A tier takes windowMs for both sides, or earlyMs and lateMs; all times are milliseconds. accuracy and holds pick the native scoring: see the guide.
| Limit | Value |
|---|---|
| Sets per mod | 8 |
| Set id, tier id | a-z, 0-9, -, 1 to 32 characters |
| Set name | 1 to 64 characters |
| Parameters | at most 8, name [A-Za-z][A-Za-z0-9]* up to 32, label up to 32, short up to 8 |
| Tiers returned | 2 to 33 (up to 32 hit tiers, then the Miss) |
| Tier name | 1 to 32 characters; color up to 9 characters; gradient 2 to 8 hex colors |
judgements.register({
id: "strict",
name: "Strict",
params: { scale: { label: "Window scale", short: "Scale", min: 0.5, max: 1.5, step: 0.1, default: 1 } },
accuracy: "weights",
holds: "head",
tiers: ({ scale }) => [
{ id: "perfect", name: "Perfect", color: "#7df9ff", windowMs: 20 * scale, weight: 1 },
{ id: "good", name: "Good", color: "#6bd36b", windowMs: 60 * scale, weight: 0.6 },
{ id: "miss", name: "Miss", color: "#ff5c5c", windowMs: 120 * scale, weight: 0, breaksCombo: true },
],
});
Errors you will see: judgement set id must be 1 to 32 characters among a-z, 0-9 and `-`, got "Strict", a mod registers at most 8 judgement sets, judgement set `x` is registered twice, tiers must return 2 to 33 tiers (hit tiers, then the miss), got 1, tier `good` needs windowMs, or earlyMs and lateMs, and param `scale` needs finite min < max, 0 < step <= max - min and min <= default <= max. The weights are checked by the game before the set is used: Wife3 tiers take no weight, continuous weights must not increase. See Writing a judgement set.
scrollSpeed.register
function scrollSpeed.register(input: ScrollSpeedDefinition): void;
Adds a scroll speed system to the settings, such as osu!mania's speed or Etterna's C-mod. The player moves a slider over param; toMs turns the chosen value into the native scroll time, the milliseconds a note takes from where it appears to the receptors. Only mods call it, and only from setup. The system is published as <modId>/<id>.
toMs(value, { travel }) must be a pure function returning a positive finite number of milliseconds. travel is the distance a note covers, in screen heights (0.8 for the native playfield). The host converts the whole slider grid (min to max by step, at most 4096 values) after the mods load, and converts a typed value on demand. A value whose call throws or returns a non-number is dropped from the grid.
| Limit | Value |
|---|---|
| Systems per mod | 8 |
id |
a-z, 0-9, -, 1 to 32 characters |
name |
1 to 64 characters |
param |
label up to 32, short up to 8; finite min < max, 0 < step <= max - min, min <= default <= max |
| Slider values | at most 4096 |
scrollSpeed.register({
id: "c-mod",
name: "C-mod",
param: { label: "C-mod", short: "C", min: 120, max: 1800, step: 5, default: 200 },
toMs: (cmod, { travel }) => ((travel * 480) / ((64 * cmod) / 60)) * 1000,
});
Errors you will see: param takes 5000 values from min to max by step; the limit is 4096, a mod registers at most 8 scroll speed systems, scroll speed system `x` is registered twice, toMs(120) threw …, toMs(120) returned string, no value converts to a scroll time: ….
Types
Definitions read from the SDK. A type used here that is defined on another page is listed under Defined elsewhere.
type ChartNotes = {
keys: number;
count: number;
seed: number;
durationUs: number;
startUs: NativeBytes;
endUs: NativeBytes;
column: NativeBytes;
kind: NativeBytes;
};
type NativeBytes = Uint8Array;
type NoteSubmission = {
startUs: NativeBytes;
endUs: NativeBytes;
column: NativeBytes;
kind: NativeBytes;
};
type GameplayModifierDeclaration = {
id: string;
name: string;
description: string;
kind: GameplayModifierKind;
group?: string | null;
icon?: string | null;
conflictsWith?: string[];
params?: ModParamDeclaration[];
};
type GameplayModifierKind = "auto" | "ghost" | "fullLn" | "chartTransform" | "noteMask" | "noPause" | "mirror" | "noLn" | "rankedFullLn" | "noMines";
type ModParamDeclaration = {
id: string;
label: string;
description: string;
section: string;
min: number;
max: number;
step: number;
default: number;
unit?: string | null;
};
type JudgementSetDefinition = {
id: string;
name: string;
params?: Record<string, JudgementParam>;
accuracy: SetAccuracy;
holds: SetHolds;
mine?: MineRule | null;
tiers: JudgementTiers;
};
type JudgementParam = {
label: string;
min: number;
max: number;
step: number;
default: number;
short?: string | null;
};
type SetAccuracy = "osuScoreV1" | "wife3" | "weights" | "continuous";
type SetHolds = "osuCombined" | "etterna" | "head" | "separate";
type MineRule = { weight?: number | null; windowMs?: number | null; };
type JudgementTiers = (params: Record<string, number>) => JudgementTier[];
type JudgementTier = {
id: string;
name: string;
color: string;
gradient?: string[] | null;
windowMs?: number | null;
earlyMs?: number | null;
lateMs?: number | null;
weight?: number | null;
breaksCombo?: boolean;
releaseWindowMs?: number | null;
releaseEarlyMs?: number | null;
releaseLateMs?: number | null;
};
type ScrollSpeedDefinition = {
id: string;
name: string;
param: ScrollSpeedParam;
toMs: ScrollSpeedToMs;
};
type ScrollSpeedParam = {
label: string;
min: number;
max: number;
step: number;
default: number;
short?: string | null;
unit?: string | null;
};
type ScrollSpeedToMs = (value: number, context: ScrollSpeedContext) => number;
type ScrollSpeedContext = { travel: number; };