Troubleshooting
Each section below starts from what you see, says why it happens and how to fix it. Everything here works with a browser and a text editor, on a computer, a phone or a tablet. When an error dialog opened, look its title up in Diagnosing Errors first.
The game is opened from its file
When you double-click index.html, the browser opens it from your disk: the address bar shows an address that starts with file://. Most of the game works that way, but Monogatari 2.9.0 has no fallbacks for the parts a browser refuses to a page opened from a file. What works opened from a file has the full list. The ones people notice first:
- Audio effects don’t apply. Music, sounds and voices play, but neither Chrome nor Firefox lets a page opened from a file read the track’s data, which the audio effects need, so Monogatari plays the track as it is. The console says Audio effects need the game to be served once.
- The dialog for a typo can’t say which line. It names the file, and Line says Not given: the browser keeps the line for its console. See A typo in one of your files.
- Offline play doesn’t work, and the console says Offline play is off: browsers only run the service worker (service-worker.js) for a game served over https, or from localhost or 127.0.0.1 on your own computer, not for an index.html opened from a file. Nothing else depends on it.
To get the whole game working, serve it: open it from a web address that starts with http:// or https://. Putting the game online does that, with no tools. Open your game lists the ways, and Share your game shows how to put it online.
The game doesn’t start after I edited a file
What you see depends on the file with the mistake:
| File | What you see |
|---|---|
js/script.js |
A dialog titled There is a mistake in js/script.js, then an empty screen. |
js/options.js |
There is a mistake in js/options.js, then the game starts with the engine’s default settings instead of yours. |
js/storage.js |
There is a mistake in js/storage.js, then the game starts without your variables. |
js/main.js |
There is a mistake in js/main.js, then an empty screen. |
The browser stopped reading that file at a typo, so nothing after it ran: in js/script.js, Monogatari never received your script. In js/main.js, the game never started. The dialog names the file and, when the game is served, the line.
The usual culprits:
A missing comma between two statements, or between two labels:
monogatari.script({ 'Start': [ 'show scene #f7f6f6 with fadeIn', // This comma 'y Hi! Welcome to Monogatari.', // and this one 'jump Ending', ], // and this one, between two labels 'Ending': [ 'y See you next time.', 'end', ], });The last statement of a label and the last label of the script don’t need one.
A quote that isn’t closed, or a line that uses the same quote inside it:
'y I can't wait'ends atcan. Write'y I can\'t wait', or use the typographic apostrophe:'y I can’t wait'.A bracket that isn’t closed. The script is an object (
{ … }), each label is a list ([ … ]), and each object statement is an object again. Every opening bracket needs its closing one.
Look at the part you changed last; the mistake is usually there. An editor that colors JavaScript helps: the colors go wrong right after the typo.
The dialog names the file and the line where the browser noticed the mistake. For a missing comma, that’s the line after the one that needs it. The message is the browser’s own and doesn’t say “comma”: for a missing comma, Chrome says Unexpected string and Firefox says missing ] after element list. In Chrome with the game opened from its file, the dialog can’t name the file or the line; the browser console does, and so does Firefox.
If the script loads and only the first label is missing, “Start” Label was not found lists the labels you have: the label’s name and the Label setting in js/options.js must be the same, capitals included.
The game stops and clicks do nothing
Something is holding the game. In order of likelihood:
- An error dialog is open. Clicks don’t move the game while it’s open. Read it and press Ok at its bottom (scroll down to reach it on a small screen). After an error about a statement, the next click goes on with the statement after it. Fix what the dialog said, save the file and reload the page.
- The label ran out of statements. Without an
'end'or a'jump'at the end of a label, the game stays on its last line, and each click opens The label “…” ran out of statements. Add'end'to finish the game, or'jump AnotherLabel'to go on. - Something waits for the player. A choice, a text input or a message waits for an answer or for Close, and clicks on the game do nothing until then. A
waitwith a time ('wait 5000') holds the game until the time is up, and some videos hold it until they end. - The text box is hidden. H, or Hide in the quick menu, hides it, and clicks don’t advance while it’s hidden. Press H again, or Show in the quick menu.
- A function of yours never finished. A function statement that returns a promise holds the game until the promise settles. One that throws an error opens a dialog, and the next click goes on after it.
On a computer, the console says which one it is: with the debug level at 4 or 5 (the starter game uses 5), each click that doesn’t move the game writes Proceed Prevented and the reason.
A line shows up as text instead of doing something
'shwo scene afternoon' or 'Show scene afternoon' shows those words in the text box instead of changing the background. Statements are case-sensitive and must be spelled exactly: 'show scene afternoon'. When no statement matches a line, Monogatari shows it as a line of narration, and no dialog opens.
The same happens to:
- statements from Monogatari v1, like
'scene afternoon','notify Welcome'or'display message Help'. See Upgrading from v1.4.1; - a character layer (
'show character y:face smile') while theExperimentalFeaturessetting isfalse, as in the starter game. See Character Layers.
It works the other way around too: a line of narration that starts with a statement’s first word runs as that statement. 'jump for joy, she said.' is a jump to a label called for, and opens The label “for” does not exist. Start the line with narrator to keep it as narration: 'narrator jump for joy, she said.' shows jump for joy, she said.
A character’s line shows as narration
'yiu Hello' shows yiu Hello with no name above it: no character has the id yiu. The word at the start of a line must match a character’s id in monogatari.characters({ … }) exactly, capitals included.
A character whose id is also a statement’s first word can’t always speak: with a character called stop, 'stop Wait for me!' runs a stop statement instead. Give the character another id. The words statements start with are show, hide, play, stop, pause, jump, wait, end, next, clear, vibrate, gallery, preload, unload and $, and centered, nvl and narrator have a meaning at the start of a line too. See Characters.
A line shows a variable’s name instead of its value
The line shows {{player.name}} with its braces, and a dialog says Variable “{{player.name}}” does not exist in your storage. Monogatari replaces each {{name}} in a line with the value of that variable, and when one doesn’t exist, it leaves it as you wrote it. (Before 2.9.0, the whole line was dropped and the text box stayed empty.)
Give every variable you use a starting value in js/storage.js, spelled the same way:
monogatari.storage({
player: {
name: '',
},
});An image, a background or a character doesn’t show
Monogatari finds an asset in two steps: the name you use in the script, declared in js/script.js, and the file it points to, in the folder for its kind inside assets/.
| Statement | Declared with | File in |
|---|---|---|
show scene afternoon |
monogatari.assets('scenes', { 'afternoon': 'afternoon.jpg' }) |
assets/scenes/ |
show image sign |
monogatari.assets('images', { 'sign': 'sign.png' }) |
assets/images/ |
show character y happy |
sprites: { 'happy': 'happy.png' } in the character |
assets/characters/, plus the character’s directory if it has one |
play music theme |
monogatari.assets('music', { 'theme': 'theme.mp3' }) |
assets/music/ |
play sound bell |
monogatari.assets('sounds', { 'bell': 'bell.mp3' }) |
assets/sounds/ |
play voice hello |
monogatari.assets('voices', { 'hello': 'hello.mp3' }) |
assets/voices/ |
show video intro |
monogatari.assets('videos', { 'intro': 'intro.mp4' }) |
assets/videos/ |
A missing image, background, sprite or video stays missing, with no dialog, and the game goes on. A missing music, sound or voice file opens a dialog that names the file, and the game goes on in silence (see Music or sound doesn’t play). Check, in this order:
- The name is declared, under the right kind. A background goes under
scenes, notimages. A scene name nobody declared isn’t an error either:show scenereads it as a color, and the background turns empty. - The file is in the folder the table says, with the exact name you wrote, extension included. Capitals count on most web servers even when they don’t on your computer:
Afternoon.jpgandafternoon.jpgare two different files once the game is online. - For a character, the
directorymatches the folder. Withdirectory: 'yui', the sprites go inassets/characters/yui/. - The file is an image your browser opens. Open it in the browser on its own; if the browser can’t show it, neither can the game.
On a computer, the console names the address Monogatari tried, in an error like Failed to load resource: the server responded with a status of 404 (served) or net::ERR_FILE_NOT_FOUND (opened from a file). Compare it with where the file really is.
The folder names come from the AssetsPath setting in js/options.js. Leave it as the starter game has it unless you moved the folders.
Music or sound doesn’t play
- The main menu music doesn’t start. Browsers don’t let a page play sound before the player has clicked or tapped it. When the browser holds the music back, Monogatari shows Click here to allow audio playback. at the top of the screen; a click on it starts the music. Nothing is wrong with your game.
- The music “…” is not defined. opens when the page loads: the
MainScreenMusicsetting names music you didn’t declare withmonogatari.assets('music', { … }). - The music “…” could not be loaded. (or The sound, The voice): the file couldn’t be loaded, and the game went on without it. The name is misspelled (Monogatari then tries it as a file name), the file isn’t in
assets/music/,assets/sounds/orassets/voices/, or the browser can’t play its format. The dialog shows the file it looked for. Fix the name or the file and reload. - A track plays, but its effect doesn’t. The game is opened from its file, or served over plain
http://forbitcrusherandautowah: see Audio effects.
Changes don’t show up after I edit a file
Save the file, then reload the page in the browser. If you still see the old version:
- Opened from its file, a reload always reads the files again. Check you’re editing the copy of the game you opened: the address bar shows its folder.
- Served, the game keeps a copy of its files so it loads fast and works offline (the service worker,
service-worker.js). Your.jsand.cssfiles come from the server on every reload. A picture, sound or font inassets/that you replaced under the same file name shows on the second reload: the first one fetches it. A reload while holding Shift skips every copy (checked in Chromium). In Firefox, a stylesheet loaded the first time you opened the game can stay old until you close Firefox and open the game again. - A game started before 2.9.0 has an older
service-worker.js, which keeps.jsand.cssfiles one reload behind and the files inassets/as it first saved them. Update its service worker.
Saves disappeared or don’t load
Saves live in the player’s browser, not in the game’s folder. They seem to disappear when:
- The game’s address changed. A browser keeps each site’s data apart: the game opened from its file, from a local server and from the web are three different places, each with its own saves.
- The
Namesetting changed. Saves are stored under the game’s name, so a new name starts with no saves. Once players have saves, keep the name. - The
Versionsetting went down. RaisingVersionkeeps the saves. When it goes down, the game goes on with the saves at the higher version they were stored with, and while you develop a dialog titled The Version … is lower than the version of the saved data names both versions. SetVersionback to that one, or higher. Before 2.9.0, a lowerVersionemptied the save and load screens. - The
Storagesetting changed. AnotherAdapterkeeps saves in another place, and so does anotherStorewith LocalStorage. With IndexedDB, the game goes on with the store the players’ saves are in, and a dialog titled The store “…” is not in the game’s database asks you to setStoreback. - The browser’s data was cleared, or the game ran in a private window, which forgets its data when it closes.
A game made with Monogatari v1 keeps its players’ saves only with the change on Upgrading from v1.4.1.
A save doesn’t appear after saving
When nothing shows up on the load screen after you saved, the browser refused to store the save. The console says why: Failed to execute 'put' on 'IDBObjectStore': … could not be cloned means your storage holds something that isn’t plain data, like a function or a page element. A save keeps the whole storage, so keep only text, numbers, true, false, lists and plain objects in it. No dialog opens for this.
See Saving and loading.
The phone says “Please rotate your device to play”
The starter game asks for landscape: 'Orientation': 'landscape' in js/options.js. On a phone held upright, the message stays until the player turns the phone sideways or presses its OK button. To let your game play either way, set 'Orientation': 'any'; for a game made for upright phones, 'portrait'.
The Skip or Back button is missing
- Skip only appears when the
Skipsetting is above0. The starter game sets'Skip': 0. The number is the time between two lines while skipping, in milliseconds:'Skip': 50turns it on. S does nothing while it’s0either. - Back only appears when
'AllowRollback': true, as in the starter game. Withfalse, ← doesn’t go back either.
The console shows warnings, but the game works
These messages are normal in Monogatari 2.9.0, and you can leave them:
| Message | Why |
|---|---|
Persistent Storage permission has been denied. When your device gets low on storage, it may choose to delete your game files. |
The browser didn’t promise to keep the game’s data when the device runs low on space. Saves still work. |
There was no settings saved. This may be the first time this game was opened, we'll create them now. |
The first time the game opens in a browser: there are no saved preferences yet. |
Offline play is off: browsers only run the service worker (service-worker.js) for a game served over https, or from localhost or 127.0.0.1 on your own computer, not for an index.html opened from a file. |
The game is opened from its file. It plays without offline support. |
Offline play is off: browsers only run the service worker (service-worker.js) for a game served over https, or from localhost or 127.0.0.1 on your own computer. This page comes over plain http from another address, so the game needs a connection to play. and AudioWorklet not supported in this browser. Some effects may not work. |
The game is served over http:// from an address other than your own computer. Browsers keep these features for https:// sites. |
The service worker couldn't keep … for offline play: … |
A file in the FILES list of service-worker.js isn’t on the host. The game plays, and offline play works without that file. Fix the name in the list, or remove it. |
Audio effects need the game to be served (from a web host or a local server): opened from a file, a track plays without them. |
The game is opened from its file and a play statement names an effect. The track plays without it. |
User denied notifications permission, none will be shown. |
A show notification statement ran, and the browser or the player blocked notifications. |
Content-Security-Policy: Ignoring 'unsafe-eval' or 'wasm-unsafe-eval' inside "script-src-elem". |
Firefox, about a rule in the index.html of a game started before 2.9.0. It changes nothing; to silence it, remove 'unsafe-eval' from the script-src-elem part of the Content-Security-Policy line near the top of index.html, as the 2.9.0 starter game does. |
An AudioContext was prevented from starting automatically. |
Firefox, before the player’s first click. Sound starts after it. |
Lines that start with [Pandora] |
The debug file lists each part of the interface as it’s added to the page. |
Still stuck
Diagnosing Errors explains every dialog and the console. When you ask for help, Help says what to include so someone can answer on the first try.