Aller au contenu

API neo

Fonctions globales que votre script définit et que NeoPiano appelle.

Fonction Rôle Capacité Statut
on_mod_init() Once, after the script is loaded (250 ms at most). Disponible
on_note_on(note, velocity) A note starts (20 ms at most per call, as every callback). Disponible
on_note_off(note) Disponible
on_tick(dt) Every frame. Disponible
on_ui(id, event, value) The player used an element of the mod’s interface. Disponible
on_setting(id, value) The player changed a setting. Disponible
on_control(number, value) API 5: a controller changed, whatever plays it (MIDI device, computer keyboard, mouse, MIDI file). Disponible
on_mod_init()
Disponible

Once, after the script is loaded (250 ms at most).

on_note_on(note, velocity)
Disponible

A note starts (20 ms at most per call, as every callback).

Paramètre Type Description
note integer MIDI note
velocity number 0-1
on_note_off(note)
Disponible
Paramètre Type Description
note integer
on_tick(dt)
Disponible

Every frame.

Paramètre Type Description
dt number seconds since the last frame
on_ui(id, event, value)
Disponible

The player used an element of the mod’s interface.

Paramètre Type Description
id string
event "click"|"change"
value any the new value (change)
on_setting(id, value)
Disponible

The player changed a setting.

Paramètre Type Description
id string
value any
on_control(number, value)
Disponible

API 5: a controller changed, whatever plays it (MIDI device, computer keyboard, mouse, MIDI file).

Paramètre Type Description
number integer 64 sustain pedal, 66 sostenuto, 67 una corda (soft), others as MIDI defines them
value integer 0 to 127 (a pedal is down from 64)
Fonction Rôle Capacité Statut
neo.api_version() Version of the neo API of the running NeoPiano (2). Disponible
neo.log(...) Writes a line to the mod log (Mods panel, Mods.log), prefixed with the mod’s name. Disponible
neo.warn(...) Like neo.log, as a warning. Disponible
neo.error(...) Like neo.log, as an error. Disponible
neo.get_note_location(note) World position of the top of the key of a note; nil without a piano. Disponible
neo.spawn_note_mesh(note, r, g, b, lifetime) A glowing sphere above the key of a note, of this color (linear, 0-1), for lifetime seconds. Disponible
neo.api_version() --> integer
Disponible

Version of the neo API of the running NeoPiano (2).

Renvoie : integer

neo.log(...)
Disponible

Writes a line to the mod log (Mods panel, Mods.log), prefixed with the mod’s name. 50 lines per second.

Paramètre Type Description
... any
neo.warn(...)
Disponible

Like neo.log, as a warning.

Paramètre Type Description
... any
neo.error(...)
Disponible

Like neo.log, as an error.

Paramètre Type Description
... any
neo.get_note_location(note) --> number?, number?, number?
Disponible

World position of the top of the key of a note; nil without a piano.

Paramètre Type Description
note integer MIDI note, 0-127

Renvoie : number?, number?, number?

neo.spawn_note_mesh(note, r, g, b, lifetime)
Disponible

A glowing sphere above the key of a note, of this color (linear, 0-1), for lifetime seconds. 200 per second.

Paramètre Type Description
note integer
r number
g number
b number
lifetime (facultatif) number seconds, 1 by default
Fonction Rôle Capacité Statut
neo.settings.define(settings) The settings of the mod, shown in Settings > Mods and in the Mods panel; values are saved. Disponible
neo.settings.get(id) The current value of a setting. Disponible
neo.settings.define(settings)
Disponible

The settings of the mod, shown in Settings > Mods and in the Mods panel; values are saved. Capability “settings”.

Paramètre Type Description
settings neo.Setting[]
neo.settings.get(id) --> any
Disponible

The current value of a setting.

Paramètre Type Description
id string

Renvoie : any

Fonction Rôle Capacité Statut
neo.storage.get(key) A value saved by the mod (nil if none). Disponible
neo.storage.set(key, value) Saves a value (nil, boolean, number, string, tables of these); 256 KiB per mod, 100 writes per second. Disponible
neo.storage.delete(key) Disponible
neo.storage.get(key) --> any
Disponible

A value saved by the mod (nil if none). Capability “storage”.

Paramètre Type Description
key string

Renvoie : any

neo.storage.set(key, value) --> boolean
Disponible

Saves a value (nil, boolean, number, string, tables of these); 256 KiB per mod, 100 writes per second.

Paramètre Type Description
key string
value any

Renvoie : boolean

neo.storage.delete(key)
Disponible
Paramètre Type Description
key string
Fonction Rôle Capacité Statut
neo.ui.panel(panel) Creates or replaces a panel of the mod in the dock. Disponible
neo.ui.hud(hud) Creates or replaces an overlay over the scene. Disponible
neo.ui.remove(id) Removes a panel or a HUD. Disponible
neo.ui.set(id, prop, value) Changes an element in place: text, label, value, options, tone, icon, visible, enabled, title. Disponible
neo.ui.toast(text, kind) A short message. Disponible
neo.ui.panel(panel)
Disponible

Creates or replaces a panel of the mod in the dock. Capability “ui.panel”; 2 panels per mod.

Paramètre Type Description
panel neo.Panel
neo.ui.hud(hud)
Disponible

Creates or replaces an overlay over the scene. Capability “ui.hud”; 2 HUDs per mod.

Paramètre Type Description
hud neo.Hud
neo.ui.remove(id)
Disponible

Removes a panel or a HUD.

Paramètre Type Description
id string
neo.ui.set(id, prop, value)
Disponible

Changes an element in place: text, label, value, options, tone, icon, visible, enabled, title. 300 per second.

Paramètre Type Description
id string
prop string
value any
neo.ui.toast(text, kind)
Disponible

A short message. Capability “ui.toast”; 1 per second.

Paramètre Type Description
text string
kind (facultatif) "info"|"success"|"warning"|"error"

Documentation synchronisée avec NeoPiano · commit cbf48cc · 17 octobre 2026