phigros.tools

Helpers

il2cpp.find(pattern)

Sorted class names matching a Lua pattern.

print(table.concat(il2cpp.find("^Score"), ", ")) --> ScoreControl
ParameterType
patternstring

Returns string[]

il2cpp.describe(class)

Every field and method of a class and its parents, for print.

print(il2cpp.describe(CS.ScoreControl))
--> ScoreControl
-->   UnityEngine.GameObject perfectJudge @0x20
-->   UnityEngine.GameObject goodJudge @0x28
-->   ...
ParameterType
classUnity

Returns string

il2cpp.class(name)

A class whose name isn't a Lua identifier (List1`).

local List = il2cpp.class("System.Collections.Generic.List`1")
ParameterType
namestring

Returns Class

il2cpp.classof(obj)

An object's class.

print(il2cpp.classof(CS.UnityEngine.GameObject("x"))) --> class UnityEngine.GameObject
local copy = il2cpp.classof(list)() -- a new object of the same class
ParameterType
objUnity

Returns Class

il2cpp.is(obj, class)

Whether an object is of a class or one deriving from it.

if il2cpp.is(loader, CS.AddressableImageLoader) then loader.Code = id end
ParameterType
objUnity
classUnity

Returns boolean

il2cpp.alive(obj)

False for nil and for destroyed Unity objects.

on("update", function()
  if not il2cpp.alive(label) then return end -- its scene is gone
  label.text = tostring(stats().combo)
end)
ParameterType
objUnity?

Returns boolean

il2cpp.typeof(class)

A System.Type.

local images = go:GetComponentsInChildren(il2cpp.typeof(CS.UnityEngine.UI.Image), true)
print(images.Length)
ParameterType
classUnity

Returns System.Type

il2cpp.string(s)

A System.String object.

local s = il2cpp.string("hello") -- for a method taking an object, where a Lua string wouldn't do
ParameterType
sstring

Returns System.String

il2cpp.bytes(s)

A byte[] of a Lua string.

local array = il2cpp.bytes("hi!")
print(array.Length) --> 3
ParameterType
sstring

Returns byte[]

il2cpp.unbytes(array)

A Lua string of a byte[].

print(il2cpp.unbytes(CS.System.Text.Encoding.UTF8:GetBytes("hi!"))) --> hi!
ParameterType
arrayUnity

Returns string

il2cpp.gc(on)

Stops the game's garbage collector, or starts it again with a collection (the core stops it during songs).

il2cpp.gc(false) -- no hitch while this runs
build()
il2cpp.gc(true)
ParameterType
onboolean

phigrospp.hex(s)

Bytes as lowercase hex.

print(phigrospp.hex("hi!")) --> 686921
ParameterType
sstring

Returns string

phigrospp.unhex(s)

Hex as bytes.

print(phigrospp.unhex("686921")) --> hi!
ParameterType
sstring

Returns string

phigrospp.base64(s)

Bytes as base64.

print(phigrospp.base64("hi!")) --> aGkh
ParameterType
sstring

Returns string

phigrospp.unbase64(s)

Base64 as bytes.

print(phigrospp.unbase64("aGkh")) --> hi!
ParameterType
sstring

Returns string

phigrospp.crypto.verify(pub, msg, sig)

Whether an Ed25519 signature is the key's (raw bytes).

local ok = phigrospp.crypto.verify(phigrospp.unhex(KEY), data, phigrospp.read(path .. ".sig"))
if not ok then return toast("Not signed by its author") end
ParameterType
pubstring
msgstring
sigstring

Returns boolean

phigrospp.phc(data)

The chart json of a .phc file.

local chart = phigrospp.json.decode(phigrospp.phc(phigrospp.read(phigrospp.dir() .. "IN.phc")))
print(#chart.judgeLineList)
ParameterType
datastring

Returns string

phigrospp.unzip(data)

The files of a zip, an error for the player when a path leaves the folder or it unpacks to too much.

local files = phigrospp.unzip(data)
for path, bytes in pairs(files) do print(path, #bytes) end --> skin/tap.png	20431
ParameterType
datastring

Returns table<string, string>

phigrospp.decode(path)

Decodes audio on a thread: job:poll() gives nothing until a float[], channels and rate.

local job = phigrospp.decode(phigrospp.dir() .. "tap.ogg")
local stop
stop = every(0.1, function()
  local samples, channels, rate = job:poll()
  if not samples then return end
  print(samples.Length, channels, rate) --> 22050	2	44100
  stop()
end)
ParameterType
pathstring

Returns { poll: fun(self): (Unity?, integer, integer) }

phigrospp.version

string

The Phigros++ running.

phigrospp.app

string

The Phigros++ the app came with.

phigrospp.native

integer

The native version the app was built for.

phigrospp.game

string

The game version the app was built for.