There are two ways to debug a running game:
- Debug View, a window built into preview and Dev builds. It shows errors, logs, variables and the chapter history without leaving the game.
- Browser DevTools, for breakpoints, stepping through code and inspecting the page.
Debug View
The Debug View is included when you run the game with Play, and in builds made with Build Mode set to Dev on the Build Panel. It isn't included in Prod builds.
To open it, click the small Mammut button on the right edge of the game. A red badge on the button shows how many errors have happened.
The game keeps running while the window is open. Keyboard and mouse input inside the window doesn't reach the game, so typing in a field won't trigger your game's controls.
Drag the title bar to move the window, and drag its bottom right corner to resize it. It remembers its position and size between runs, except in the desktop app's preview, where it resets each time.
Errors
Check this tab first. If new errors have happened, the window opens on it automatically. It collects:
- Errors that your code throws and nothing catches, including rejected promises.
- Scripts and images on the page that fail to load.
- Anything logged with
logError()orconsole.error().
Each entry shows the time, the message, the file and line, and the scene that was running. Expand Stack to see the full stack trace.
If the same error happens again, it stays as one entry with a count such as ×12, so an error in a loop won't flood the list. Clear empties the list and resets the badge.
Errors are only recorded, not caught, so your game behaves the same with or without the Debug View.
Log
Shows everything sent to log(), logWarning() and logError() (see Coding), plus direct console calls, each with its time and the file and line it came from.
- The log, warn and error buttons turn each level on or off.
console.info()andconsole.debug()count as log. - Filter only shows entries containing your text.
- Clear empties the list.
The list follows the newest entry unless you've scrolled up, and keeps the latest 2000 entries.
Variables
Shows live values while the tab is open, under these headings:
- Project variables: the Variable Store.
- Scene: the
varsof the current scene. - Attached scene: the
varsof each attached scene.
You can change values while the game runs. True or false values use a tick box, numbers and text use a field, and objects, arrays and null use a field containing JSON. Press Enter or click away to apply a change. If the value isn't valid, the field is outlined in red and the change isn't applied.
Some values can't be changed. scene and paused belong to the engine, and anything that can't be written as JSON, such as a DOM element or a function, is shown as read-only.
Changing a project variable uses Store.Set, so anything listening for that variable reacts straight away. Changing a scene variable only sets the value, so you'll see the effect the next time your script reads it.
Chapter
Lists every chapter node the Revealer has shown, oldest first, with the time, the chapter name, the node ID and a short preview of the text. It keeps the latest 1000 nodes.
You can read the same list from a script with Revealer.GetHistory().
This tab needs the Narrative module to be on. If your project overrides revealer.js, your version needs its own GetHistory() for this tab to work.
Browser DevTools
When the game is running in a browser, you can also point your browser's own DevTools (Normally f12) at wherever it's running:
- Popup window: open DevTools and use its target/context switcher if you have several windows open, or just open DevTools on the popup itself.
- Itch.io-embedded iframe: right-click inside the game and choose Inspect, or pick that frame from DevTools' console context dropdown.
DevTools aren't available in the desktop app's preview window, so use the Debug View there.
Once you're pointed at the right context, everything works as you'd expect:
log(),logWarning(), andlogError()(see Coding) print straight toconsole.log/warn/error, prefixed with the real calling file and line, not the logger's own internals.- The runtime's managers,
Store,Assets,Revealer,SceneManager,AudioManager,InputManager,Application,SaveManager, are all plain globals, since the runtime scripts are loaded as classic<script>tags rather than modules. That means you can poke at live state directly, e.g. typingStore.Get("playerName")orSceneManager.GetCurrentScene()straight into the console.