Welcome over! If you've written Psych Engine Lua before, you already know most of this - the ideas are the same,
only some names are different. This page walks through Psych's Lua API
in the order it's sorted there - script types, callbacks, then the function pages one by one - and tells you what each
thing is called in a .event file.
Keep it open in a tab while you port your first song. After that, you probably won't need it much.
A handful of things work differently on purpose. Once these click, the rest is mostly renaming:
One file per event. Psych splits a custom event into Name.lua + Name.txt; here it's one .event
file with an event { } header, a params { } block for the editor's controls, and the code.
Lanes in their own file. Whatever moves the lanes and notes (noteTweenX, setPropertyFromGroup('strumLineNotes', ...),
modcharting tools) goes in a .modchart file next to it - same layout, same callbacks
(why).
No setProperty strings. Everything you can change has its own name (camera.zoom, strum[2].x,
player.pose). The upside: a typo is an error the moment the file loads, with a "did you mean ...?" - instead of
silently doing nothing while you wonder why.
No tags. Psych names every sprite, tween and timer with a tag. Here texts and pictures are slots
(text[0] ... text[7], image[0] ... image[63]), a tween belongs to the property it moves, and timers
only need a name if you want to cancel them.
Durations are milliseconds, written beats(2), steps(4) or seconds(1) - they follow the song's
tempo by themselves.
No globals. Declare every variable with local (or shared, to share it between files).
The characters are Minecraft players.boyfriend and dad are the two fighters in the world (player,
opponent) during a fight. In practice at the Retro TV there's no world, so they're the two puppets next to the
lanes.
image[0].shader = "my.frag" on one sprite, or shader[0].file = "my.frag" on the whole picture, the world, or the world behind the fighters - the Psych .frag file as it is (your own shaders)
setShaderFloat(tag, name, value)
setShaderFloat(slot, name, value) - int / bool uniforms too
setShaderFloatArray
not available - use single values
ready-made shader effects
the built-in fx.*: chromatic, bloom, blur, glitch, wave, ...
Here's a Psych event that flashes the screen and zooms in, with the colour in value1 - and the same thing here:
function onEvent(name, value1, value2)
if name == "Flash Zoom" then
cameraFlash("camGame", value1 ~= "" and value1 or "FFFFFF", 0.5)
doTweenZoom("fz", "camGame", 1.2, 0.5, "sineOut")
runTimer("fzBack", 2)
end
end
function onTimerCompleted(tag)
if tag == "fzBack" then
doTweenZoom("fz", "camGame", 1, 0.5, "sineInOut")
end
end
format2.0event{name="Flash Zoom",description="Flashes and zooms in, back after two seconds.",}params{tint=color{from="value1",default=#FFFFFF,label="Colour"},}functiononEvent(p)flash(p.tint,seconds(0.5))zoom(1.2,seconds(0.5))after(seconds(2),function()zoom(1,seconds(0.5))end)end
Notice how much shorter it got? No name check, no timer tag, no onTimerCompleted. And the params block gives the
event a real colour picker in the chart editor - while the chart file still stores value1 as text, just like Psych.
So a Psych chart's events keep their values when you bring it over.
Some of Psych's Lua can reach into the whole game - and into your computer. MineFunkin's scripts can't, and that's
a feature: a song you download can't do anything to your game or your files. So these are gone for good:
runHaxeCode / HScript, and reaching any object by name (setProperty on whatever exists,
getPropertyFromClass) - a script gets the properties of this wiki, nothing else;
reading and writing files, save data (initSaveData, flushSaveData), the clipboard, the internet;
loading more scripts while the song runs (addLuaScript), changing the chart or the stage files;
setting the score or misses.
Everything else a Psych chart usually does - tweens, timers, sprites and animations, texts, the camera, the
characters, the notes one by one, sounds, health, shaders, even the game window - has a counterpart above. If you get
stuck on something that isn't listed, the FAQ is a good next stop.