Limits, the event log and versions¶
Limits and safety¶
Why limits at all? Because you'll download songs from people you don't know, and a song should never be able to freeze your game - by accident or on purpose. The limits are generous; a normal song never gets near them. If yours does, the event log tells you which one.
- One call into the scripts (an event, a frame, a hit) may run at most 500,000 statements.
- A
forloop may run at most 100,000 rounds. Functions may call each other at most 64 deep. - At most 8,192
afters andeverys may wait at once. Aneveryruns at most once a frame. trigger: events may trigger each other at most 8 deep.- A script that fails while running is switched off for the rest of the run, and the failure is logged with its line. Examples: a lane that doesn't exist, text where a number is needed, a choice property set to a word it doesn't take.
- Writing a non-number (a division by zero) to a number property is ignored.
- Opacities and volumes go from 0 to 1 (
hud.bars0-3,camera.nudge0-5). A constant outside that is an error when the file loads; a value worked out while the song runs is kept inside, and the log says so once. log: at most 200 lines per event per run.- Texts: at most 16,384 characters. Making a longer one - joining with
../+/+=,upper,lower,replace- switches that script off (it isn't cut short). - Top-level
locals get their starting values when the song starts, so they can read the game (local w = screen.width). One that fails there switches its script off. - Pictures:
.png, at most 8192 pixels a side and 16 MB as a file, at most 512 different pictures and 512 MB of video memory per song. They are freed when the song closes. A sprite's.xml: at most 2 MB and 4096 frames. A video folder: at most 20,000 frames (.jpg/.png), 2048 pixels a side, 8 MB a frame. - Shaders:
.fshor.frag, at most 32 KB a file, at most four at once. Which run is the player's choice (the shader check); one that takes over 25 ms a frame is switched off. - Skins (
setSkin,player.skin): 64x64.png, at most 1 MB each and 8 per song. - Windows: at most eight pop-outs, each at most 4096 pixels a side. The game window keeps 64 pixels on its monitor, at least 0.2 opacity, one full-screen flip a second. All of it only while the song plays, and only if the player allows it (Options › MineFunkin › Song effects › "Let songs use windows").
- Sounds:
.ogg, at most 5 minutes each (longer ones aren't played - the log says so), at most 32 of a song's own sounds playing at once (one more is left out, said once). Each is decoded once per song and let go when it closes. - Modifiers: at most 200,000 planned changes per song (one per field each
ease/set/addtouches; past that they're left out, said once), 8 playfields (yours, the opponent's, 6 fromcopyField), 256 modifiers of your own (customMod). A value is kept within ±10,000,000; oneeaselasts at most 100,000 beats. - Sounds, pictures and shaders are only found inside the song's own folder (and its
events/folder, orshaders/for shaders). A path that leads out of it is refused.
Error messages and what to do about them: Errors and fixes.
The event log¶
logs/minefunkin-events.log, next to latest.log, collects everything that happens with events. It starts fresh
every time the game starts; the one before is kept as minefunkin-events.prev.log. It writes down:
- the built-in events, and per song the event files it brings (and which built-in each replaces);
- every file that can't be used, with the reason (also listed in the chart editor);
- every song start (mode, chart event count), chart events no file defines, and events switched off in the options;
- every chart event as it fires, with its values;
- script errors, missing sounds, pictures or shaders, shaders that don't compile (with the driver's
message), and the scripts' own
loglines.
Warnings and errors also go to latest.log. Past 8 MB the file only takes warnings and errors.
Versions¶
The first line of every file says which version of the language it's written in. Write every file as
format 2.0:
| Version | |
|---|---|
format 2.0 |
The one to write - every file starts with it. |
format 1.1 |
Runs exactly like 2.0, nothing to change. |
format 1.0 |
MineFunkin's development builds before the first release. It doesn't run anymore: Song Select's update button turns a song's 1.0 files into 2.0 in one go - see old songs. |
| anything else | A version newer than this MineFunkin. Not run; it's listed as a problem: "written for event format 2.1, this MineFunkin runs 2.0 and 1.1 - a newer MineFunkin is needed". |
Versions before 2.0 were prototypes - 2.0 is the real start. The same goes for song files and the Addon API.
Some names came to the language after its first files were written: note, notes, every, cancel, stopTween,
loopSound, trigger, call, callIn, preload, setHealth, addHealth, stopSound, soundVolume, randomInt,
sub, find, replace, trim, startsWith, endsWith, noteSlot, boyfriend, dad, bind, unbind,
inspect, atPlace. They stay yours if a file already uses them for its own
things: a variable or parameter of that name (function onHit(note)) hides the built-in one inside it, and a
function of the file's own (local function preload(...)) is called instead of the built-in.
Old songs and the update button¶
Just so you know
You most likely won't need this. Every released MineFunkin uses format 2.0, and only songs made with the development builds before the first release are in an older format. This section is here so you know how it works if a later MineFunkin ever moves on from 2.0 - old songs will then be updated the same way.
A song with any file in an old format - an event file in format 1.0, or a chart or song file in the old song
format 1 - shows up in Song Select with a yellow ⚠, and can't be played yet. Don't worry, fixing it is one click:
select it and press Update all old songs (or ⋯ › Update old songs), and every such song is converted at once:
- Charts and song files are written in format 2.0. The notes, events, BPM changes and audio links stay exactly as they were.
- Event files get
format 2.0as their first line, and nothing else changes - with one exception: a name the file used for its own things that 2.0 uses itself (a variable calledvolume, a function calledzoom, a helper calledonPause, which 2.0 would start calling by itself) is renamed tomyVolume,myZoom,myOnPause, and a comment under the format line lists what was renamed. - Every original is copied into the song's
backup/folder first, just in case.
On a server, the admin converts the songs in server_songs/ with /minefunkin convert. The server log says at
start when there are old songs.