Events
on(event, function) runs the function each time the event happens. Reacting to the game walks through the ones used most.
| Event | When | The function gets |
|---|---|---|
update | every frame | |
load, unload | the mods loaded, they're about to reload | |
scene | the game changes screen, and once after load | its name: "ChapterSelector", "SongSelector", "Level"... |
setting | the player changed a setting | its label and value |
song | a song starts | the Chart |
chart | a song's Chart as the game loaded and mirrored it, before it's laid out: what it's given then is what plays | the game's Chart |
hit | a note is judged | a Hit |
pause, resume | the player pauses or comes back | |
leave | the song is quit, retried or finished | |
finish | the song ended | its Stats |
jump | the song jumped (phigrospp.jump) | the time jumped to |
restart | the song was put back at its start (phigrospp.restart) | |
replays | a replay was recorded or deleted | |
best | a recorded play beat or tied the chart's record (with modifiers: the best of the player's replays with the same ones) | its replay's path |
link | the app was opened or brought back by a phigrospp:// link | the url |
room | the room the player is in changed (Rooms) | the room, nil once out of it |
| anything else | phigrospp.emit was called with it, for mods talking to each other | what it was given |
on(event, fn)
Runs the function each time the event happens.
on("hit", function(hit) if hit.judgement == "miss" then print("missed a " .. hit.note) end --> missed a flick end) on("finish", function(result) toast(("%d, %.2f%%"):format(result.score, result.accuracy)) --> 996761, 99.68% end)
| Parameter | Type | |
|---|---|---|
event | Event | |
fn | function |
phigrospp.emit(event, ...)
Runs the on(event) handlers with these arguments.
-- in one mod phigrospp.emit("section", 42.5, 60) -- in another on("section", function(from, to) print(from, to) end) --> 42.5 60
| Parameter | Type | |
|---|---|---|
event | string | |
... | any |