API neo
Callbacks
Section intitulée « Callbacks »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
Section intitulée « on_mod_init »on_mod_init()Once, after the script is loaded (250 ms at most).
on_note_on
Section intitulée « on_note_on »on_note_on(note, velocity)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
Section intitulée « on_note_off »on_note_off(note)| Paramètre | Type | Description |
|---|---|---|
note |
integer |
on_tick(dt)Every frame.
| Paramètre | Type | Description |
|---|---|---|
dt |
number |
seconds since the last frame |
on_ui(id, event, value)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
Section intitulée « on_setting »on_setting(id, value)The player changed a setting.
| Paramètre | Type | Description |
|---|---|---|
id |
string |
|
value |
any |
on_control
Section intitulée « on_control »on_control(number, value)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
Section intitulée « neo.api_version »neo.api_version() --> integerVersion of the neo API of the running NeoPiano (2).
Renvoie : integer
neo.log(...)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
Section intitulée « neo.warn »neo.warn(...)Like neo.log, as a warning.
| Paramètre | Type | Description |
|---|---|---|
... |
any |
neo.error
Section intitulée « neo.error »neo.error(...)Like neo.log, as an error.
| Paramètre | Type | Description |
|---|---|---|
... |
any |
neo.get_note_location
Section intitulée « neo.get_note_location »neo.get_note_location(note) --> number?, number?, number?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
Section intitulée « neo.spawn_note_mesh »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. 200 per second.
| Paramètre | Type | Description |
|---|---|---|
note |
integer |
|
r |
number |
|
g |
number |
|
b |
number |
|
lifetime (facultatif) |
number |
seconds, 1 by default |
neo.settings
Section intitulée « neo.settings »| 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
Section intitulée « neo.settings.define »neo.settings.define(settings)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
Section intitulée « neo.settings.get »neo.settings.get(id) --> anyThe current value of a setting.
| Paramètre | Type | Description |
|---|---|---|
id |
string |
Renvoie : any
neo.storage
Section intitulée « neo.storage »| 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
Section intitulée « neo.storage.get »neo.storage.get(key) --> anyA value saved by the mod (nil if none). Capability “storage”.
| Paramètre | Type | Description |
|---|---|---|
key |
string |
Renvoie : any
neo.storage.set
Section intitulée « neo.storage.set »neo.storage.set(key, value) --> booleanSaves 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
Section intitulée « neo.storage.delete »neo.storage.delete(key)| 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
Section intitulée « neo.ui.panel »neo.ui.panel(panel)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
Section intitulée « neo.ui.hud »neo.ui.hud(hud)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
Section intitulée « neo.ui.remove »neo.ui.remove(id)Removes a panel or a HUD.
| Paramètre | Type | Description |
|---|---|---|
id |
string |
neo.ui.set
Section intitulée « neo.ui.set »neo.ui.set(id, prop, value)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
Section intitulée « neo.ui.toast »neo.ui.toast(text, kind)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