Reacting to the game
on(event, function) runs your function when something happens in the game. This mod cheers every 100 combo and writes the result of each song to the log:
local name on("song", function(chart) name = chart.name .. " " .. chart.difficulty -- "Glaciaxion IN" end) on("hit", function(hit) if hit.combo > 0 and hit.combo % 100 == 0 then print(hit.combo .. " combo!") end end) on("finish", function(result) toast(("%s: %d, %.2f%%"):format(name, result.score, result.accuracy)) -- shown once the song is left end)
The events you'll use most:
| Event | When | What your function gets |
|---|---|---|
scene | the game changes screen | its name: "SongSelector", "Level"... |
song | a song starts | the chart: id, name, difficulty, level, notes... |
hit | a note is judged | judgement ("perfect", "good", "bad", "miss"), offset in ms, combo |
pause, resume | the player pauses or comes back | nothing |
finish | the song ends | the final stats |
update | every frame | nothing |
During a song, stats() gives the play so far (score, accuracy, combo, maxcombo, perfect, good, bad, miss...), and playing() the chart being played. replaying() is true while a replay is shown, so a mod can stay quiet then.
Mods watch the game, they never change how it plays: scores stay fair and replays stay true. The Modifiers are the one exception: what they change is written in the replay and judged again by phigros.tools, and their plays never reach the save. A mod that changes a play any other way calls phigrospp.counts(false).
Everything else (the player's records, songs, touches, timers) is in Mod API.