How callbacks are dispatched
TheScriptManager dispatches callbacks using several internal methods depending on the argument signature needed:
| Internal method | Used for |
|---|---|
call(name) | Callbacks with no arguments |
call_with_elapsed(name, dt) | onUpdate, onUpdatePost |
call_note_hit(name, ...) | Note hit/miss callbacks |
call_beat(name, beat) | onBeatHit |
call_step(name, step) | onStepHit |
call_event(name, v1, v2) | onEvent |
Song lifecycle
onCreate
Fired once when the song scene initializes, before the countdown starts.
onCreate to create Lua sprites, initialize custom variables, and set up anything that needs to exist before gameplay begins.
onCreatePost
Fired after onCreate completes and all engine setup is done.
onUpdate
Fired every frame during gameplay.
Time in seconds since the last frame (delta time).
onUpdatePost
Fired every frame after all engine update logic runs.
Time in seconds since the last frame (delta time).
onSongStart
Fired when the song audio begins (after countdown).
onEndSong
Fired when the song finishes playing, before the results screen.
Note events
Note event callbacks all share the same four arguments.The note’s index in the members array. Use with
getPropertyFromGroup to read other note properties.The lane index:
0 = left, 1 = down, 2 = up, 3 = right.The note type string, e.g.
"" (default), "Hurt Note", "Alt Animation".true if this is a hold/sustain note tail, false for the note head.goodNoteHit
Fired when the player hits a note successfully.
opponentNoteHit
Fired when the opponent (dad) hits a note.
noteMiss
Fired when the player misses a note (it scrolled past without a hit).
noteMissPress
Fired when the player presses a key with no note to hit (ghost tap).
noteMissPress only fires when ghostTapping is false. With ghost tapping enabled (the default), pressing keys with no notes does not count as a miss.onSpawnNote
Fired when a note is spawned from the unspawn pool (before it appears on screen).
Beat, step, and section
onBeatHit
Fired on every beat of the song. curBeat is updated before this callback runs.
onStepHit
Fired on every step (4 steps per beat). curStep is updated before this callback runs.
onSectionHit
Fired at the start of each chart section (1 section = 16 steps by default). curSection is updated before this callback runs.
Custom events
onEvent
Fired when the chart triggers a named custom event.
The event name as defined in the chart editor.
First event value (always a string; parse numbers with
tonumber).Second event value.
eventEarlyTrigger
Return a number of milliseconds to fire an event early. Useful for syncing visual effects to audio.
The event name being queried.
Tween and timer completion
onTweenCompleted
Fired when a tween finishes.
The tag string passed to the tween function (e.g.
doTweenX).The tween target identifier.
onTimerCompleted
Fired each time a timer loop completes (once per loop, not just on final completion).
The tag string passed to
runTimer.How many loops have completed so far.
How many loops remain.
0 means the timer is fully done.