phigros.tools

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:

EventWhenWhat your function gets
scenethe game changes screenits name: "SongSelector", "Level"...
songa song startsthe chart: id, name, difficulty, level, notes...
hita note is judgedjudgement ("perfect", "good", "bad", "miss"), offset in ms, combo
pause, resumethe player pauses or comes backnothing
finishthe song endsthe final stats
updateevery framenothing

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.