Sound, loading and language
On this page
Sound
- Loops with intros: Reads the
LOOPSTARTandLOOPLENGTH(orLOOPEND; both in samples) embedded in OGG (Vorbis, Opus) tracks and repeats the section after the intro (a format widely used for game music). If you writeloop-startandloop-endon@bgm, those take priority. When the mobile version compresses audio (build.mobile.audio), AAC (.m4a) loses the tags, and Opus changes the sample rate to 48000 so the counts no longer match, so the export puts the positions (in seconds) read from the original track inproject/audio-loops.json, and the player uses them before the embedded tags (tracks converted to Opus also get tags converted to counts at 48000). Studio’s BGM loop markers are written toloop-startandloop-end(in milliseconds) of@bgm, so they don’t depend on the format - Cross-fade:
@bgm theme crossfade=2sloads the new track first, then fades the current track out while fading the new one in (the current track keeps playing while loading) - Streaming long BGM: BGM larger than 1MB isn’t decoded all at once; it plays with
<audio>, loading a little at a time, and goes through Web Audio for volume, panning, fades, cross-fades and lowering during voice (a 4-minute track takes about 90MB when decoded). Loop points (loop-startandloop-endof@bgm,project/audio-loops.json, and embedded tags, read from the first 256KB), pause and resume, save and load, and the music room’s seek bar all work the same way. For the loop section, it checks the end position every 10ms and jumps back to the start of the section, so the seam isn’t as precise as with decoded playback (off by about 10ms). The host of the browser version, the desktop version (encrypted or not) and the Android app respond to range requests (Range). When the host doesn’t respond, and when playback fails (because of autoplay restrictions and so on), it decodes and plays as before.ui.sound.streamBgm: falseturns this off (for games that need precise seams) - Cache of decoded sounds: Each kind has its own limit, and when it’s exceeded, the sounds unused for the longest are discarded (BGM 48MB, sound effects 32MB, voice 24MB; previously 192MB in total).
Sounds played as text appears (
@text-sound) are limited to 16 - Panning and playback speed:
pan(-100 is left, 100 is right) andrate(1 is normal speed; the pitch changes too) of@bgmand@se. They’re kept through save and load, and after pausing - Pause: The position where
@pause-bgmstopped is kept in saves (bgm.pausedAtin the state), and@resume-bgmafter loading continues from there (saves from earlier versions and@resume-seplay from the start) - System voice (
ui.systemVoice): Lists candidate sounds from thevoicefolder fortitle(when the title screen appears; a title call),actions(when the player does something: the title’sstart,load,extra,flowchart,config,exit, and menu actions such assave,load,auto,skipandbacklog) andconfirm(confirmation dialogs). A candidate is a file or{ "file": …, "if": "system.cleared", "character": "A" }, and one is picked from those whoseifis true (such as a title call only after the game is cleared). If you writecharacter, “System voice” (“Random,” each character, “Off”) appears on the “Sound” tab of Settings.volume(0–100) is the overall volume. System voices follow the voice volume and don’t stop voices in the script - System sound effects (
ui.sound.ui): Write sounds from thesoundfolder forhover(when the mouse moves over a button, and when one is selected with keys or a gamepad),select(when one is pressed),cancel(when going back with a close button, “No” in a confirmation, Esc, right-click or B on a gamepad),openandclose(when a screen opens or closes; not right after a press sound),page(when switching tabs) andchoice(when choosing an option). They play at the sound effect volume. They play both on the default system screens and on plugin parts (ui.button,ui.toggle,ui.choice;soundchanges the kind, andfalsesilences them), and project screens can play them withui.playSound("open") - Volume preview (
ui.settings.samples): When the player finishes moving the BGM, sound effect or voice volume in Settings, the sound written inbgm,seorvoiceplays once at that volume (the master volume uses the sound effect’s). The BGM preview plays only when no BGM is playing (on the title and so on), and stops when Settings closes
Loading and performance
- Preloading: Each time a page is shown, it loads the backgrounds, sprites, images, sounds and numbered voices used in the next 40 commands (both sides of branches).
If an
@jump,@callor choice target in that range is in another file, it loads that file and also the assets of the first 24 commands at the target (for a label in the same file but outside the range, it loads its assets). Up to 4 new jump targets are loaded per page. Targets given as expressions (@jump (game.next)) aren’t loaded. Errors in preloaded files are reported when the game actually jumps to that file (errors beyond branches that aren’t taken don’t appear) - High-resolution displays: The game screen is built in px of game coordinates and scaled up to fit the display. The top-left of the scaled game screen is aligned to the display’s pixels
(placing it at fractional positions blurs text and images. It’s aligned again when the window moves to a display with a different pixel density). What’s drawn on canvases
(
@particles, WebGL effects of@effect, swaying sprites) is drawn at the display’s resolution, multiplied by the scale and devicePixelRatio (particles and WebGL effects up to 2x, swaying sprites up to 3x and 2048px). The shader’su_resolutionstays in game screen px. Nothing gets sharper than the asset images themselves, so for games played on large displays, prepare backgrounds and sprites as images larger than the screen - Offline: The exported browser version can be played offline once it has been opened (it caches with a Service Worker;
build.browser.offline; distribution.md) - Startup: The small files read at startup (the asset list, the export version, the pack list and the characters) are fetched all at once. While they load,
after 0.5 seconds a thin-line loading indicator appears in the center of the screen (
#lm-bootinindex.html; removed when the game screen appears) - Waiting for assets: When showing a background, sprite and so on has to wait more than 0.5 seconds for loading, a small waiting mark (
.lm-busy) appears at the bottom right of the game screen, and disappears when loading finishes (not for preloading). Change its look by writing.lm-busyin the project’s CSS - New version: When a new export is put up while someone is playing the exported browser version, “A new version is available” and “Reload” appear at the top (offline in distribution.md)
- Lower resolution for phones: In the asset compression settings (
build.mobile,build.browser.compress,build.desktop.compress), setimages.scaleto a factor greater than 0 and less than 1 to export backgrounds and sprites (images.scaleFolders;bgimageandfgimageby default) with their width and height scaled by that factor (WebP assets are re-encoded too; cwebp is needed). The game shows them at their original size, so sprite layout,@imagesizes and crops, the face window and save thumbnails don’t change (the export writes the original sizes toproject/assets-scale.json, and<img>gets a srcset width and sizes). UI images (image) aren’t scaled by default, because the size of their frame corners (imageSlice) is written in pixels. Pictures shown with CSSurl()are stretched to fit, so they stay as they are
"build": { "mobile": { "images": { "quality": 80, "scale": 0.5 } } }
Language
If the game is multilingual (languages in liminalia.json), the player can choose the language in Settings. If none is chosen, the game starts in the language that matches the browser (device),
or in the original language if none matches. Writing ?lang=en in the URL starts that session in that language, if it’s in languages (the language remembered in Settings isn’t changed; for example, when opening from per-language pages of a website). The system screens have built-in Japanese and English text, and other languages override it with ui in the translation file
(format.md chapter 10, multilingual). Changing the language also changes the page’s <html lang> (so that screen readers read it correctly).