Repository navigation
Mod API
molly edited this page Nov 12, 2026
·
1 revision
A mod is mods/<name>.lua or mods/<name>/init.lua, run in name order. Names starting with _ are skipped. Mods
are loaded with require, so a mod can require("other") and get what it returns.
local UE = CS.UnityEngine -- any class by full name
local go = UE.GameObject("name") -- calling a class runs its constructor
local image = go:AddComponent(UE.UI.Image) -- a class passed for a System.Type becomes that type
image.color = { 1, 1, 1, 0.5 } -- structs are tables, by field name or in order
print(image.transform.anchoredPosition.x) -- fields, properties and methods by name
hook(CS.ScoreControl, "Perfect", { -- runs around a game method
before = function(self, noteCode, judgeTime) end,
after = function(self, noteCode, judgeTime, pos, flag, result) end, -- returning a value replaces the result
})
on("update", function() end) -- every frame, also "load" and "unload"
local enabled = setting("Show the thing", true) -- a toggle in the Phigros++ settings tab, saved
local other = setting("Other thing", false, "My mod") -- or in a tab of its own
local size = setting("Size", 1.0, { 0.5, 2 }) -- a slider, whole numbers when the default is one
local offset = setting("Offset", 0, { -100, 100, step = 5, unit = "ms", hint = "*Shown under it" })
-- with a step: - and + buttons and the value on the right
local style = setting("Style", "osu", { "osu", "classic" }) -- a choice, tapping it picks the next one
button("Open the log", function() end) -- a button running a function
link("Open the log", function() end) -- a label with the game's arrow button, as on its Misc page
button(function() return "Score: " .. n end, fn) -- a label can be a function, the button follows what it returns
button("Reset", fn, "My mod", function() return enabled() end) -- shown only while the function returns true, and
-- a setting takes the same last argument
progress(function() return done, "Downloading" end) -- a bar filled from 0 to 1, with a text in its middle or
-- { left =, center =, right = }, redrawn every frame
tab("My mod", function() return enabled() end) -- a tab shown only while the function returns true, the tab
-- "Profile" puts rows on the game's Profile page
if enabled() then end
enabled(false) -- sets it, as if the player had
on("setting", function(label, value) end) -- the player changed a settingEverything below hands out plain Lua copies: mods watch the game, they never steer it.
on("scene", function(name) end) -- "ChapterSelector", "SongSelector", "Level"... also once after load
after(2, fn) every(0.5, fn) -- both return a function that cancels them
toast("Saved") -- an Android toast
local sprite = image("logo.png") -- a Sprite from a png or jpg next to the mod's filePages over the song list are made of copies of its own parts, so they look and move like the game.
local ui = phigrospp.ui
ui.sideButton(play, 1, sprite, fn) -- a copy of a play button one slot left of it, showing a sprite
local page = ui.page() -- slides the song list out to the left and an empty page in
page:part("cover") -- a copy of a song list part where it is: topbar, shadows, info
-- (record panel), cover, selected, up, down, back, play
page:back() page:play(fn) -- the back button closes the page, the play button runs fn
page:list({ count = n, row = fn, selected = fn, select = fn }) -- the song list's list: row(row, i) sets a
-- SongListItem, selected(row, i) the middle one's songName, artist,
-- level and levelText, select(i) runs when it changes
page:close() -- slides back
if ui.confirm({ title = "Delete replay", message = "...", yes = "Delete", danger = true }) then end
-- the game's popup, from a button's function or a coroutine:
-- waits for the choice and returns true for yes, danger makes yes
-- red, no = false leaves yes alone, yes = false no alone,
-- grid = { cells = list, columns = n } in aligned columns,
-- input = a placeholder: a text box, its text returned second,
-- progress = fn returning (0 to 1, message): a bar, redrawn
ui.close(...) -- closes the open popup, its confirm returning what's given
phigrospp.share("https://phigros.tools") -- Android's share sheet for a text
phigrospp.feature("android.hardware.telephony") -- whether the device has an Android hardware feature
on("replays", fn) -- a replay was recorded or deleted
on("best", function(path) end) -- a recorded play beat or tied the chart's record, path is its replay
phigrospp.read(path) phigrospp.write(path, data) -- a whole file, written through a temporary one, bundle/<path>
-- reads a file of the bundle
phigrospp.fetch("GET", url, body, function(status, body) end) -- an HTTP request, returns its UnityWebRequest
phigrospp.find(transform, "A/B") -- a child, the error names what's missing after a game update
on("song", function(chart) end) -- a song starts: {id, name, difficulty = "IN", level = "15", notes...}
on("hit", function(hit) end) -- {judgement = "perfect", offset = -12.5, combo = 40}, offset in ms (nil for misses, drags and flicks)
on("pause", fn) on("resume", fn) on("leave", fn) -- leave is quitting, retrying or finishing
on("finish", function(result) end) -- the song ended, result is stats()
playing() -- the chart being played, or nil
stats() -- {score, accuracy, combo, maxcombo, fc, ap, perfect, good, bad, miss...}
touches() -- this frame's fingers {id, phase, x, y}, screen pixels, replayed ones while watching (none while paused)
replaying() -- true while a replay plays
songs() song("Glaciaxion.SunsetRay.0") -- {id, name, composer, illustrator, charts = {IN = {constant, charter}}}
rks() language() -- the player's RKS (0 until the game computes it), "english"...
phigrospp.tag() -- the player's "name#0042" on phigros.tools, nil without a profile
records() -- every chart the player has a record on:
-- {id, difficulty = "IN", score, accuracy, fc}, read from the save
appearance() -- {avatar, background} the player picked, "" for the game's
grade(996761, true) -- the game's letter for a score, "φ", "V", "S"... "F"
phigrospp.emit("my-event", ...) -- runs on("my-event") handlers, for mods talking to each otherCosmetics take files next to the mod's file. They change how the chart looks, never what it tells the player.
hitsound("tap", "tap.wav") -- tap (also holds), drag or flick, 16 bit pcm wav
skin.note("tap", "tap.png") -- tap, drag, flick, or tap_multi... for notes hit together,
-- scaled to fit inside the game's note
skin.line({ ap = "#ffd27f", fc = "#7fd4ff", normal = "#ffffff" }) -- judge line colours, the chart keeps its alpha- Overloads are picked from the arguments. To hook an overloaded method, pass its parameter count or type names:
hook(Class, "Name", 2, callbacks)orhook(Class, "Name", { "System.Single", "*" }, callbacks). - Numbers, booleans and strings convert both ways, enums are integers, arrays index from 0 like in C#.
- Unity calls are only safe on the main thread: in
on("update"), in hooks on game methods, and at load. - Unity objects a mod creates (constructors,
Object.Instantiate) are destroyed before every reload.on("unload")is only needed for anything else.
| Helper | |
|---|---|
il2cpp.find(pattern) |
Sorted class names matching a Lua pattern |
il2cpp.describe(Class) |
Every field and method of a class and its parents, for print
|
il2cpp.class(name) |
A class whose name isn't a Lua identifier (List1`) |
il2cpp.classof(obj), il2cpp.is(obj, Class)
|
Runtime class checks |
il2cpp.alive(obj) |
False for nil and for destroyed Unity objects |
il2cpp.typeof(Class), il2cpp.string(s)
|
A System.Type or System.String object |
il2cpp.bytes(s), il2cpp.unbytes(array)
|
A byte[] of a Lua string, and back |
unhook(id), now()
|
|
phigrospp.version, phigrospp.app
|
The Phigros++ running, and the one the app came with |
phigrospp.native, phigrospp.game
|
What the app was built for |