Project Mammut Wiki
projectmammut.com
Project Mammut is currently in open beta. The UI is being updated a lot during this time, and you may run into bugs. If you'd like to help develop the engine or suggest features, come find us on Bluesky or Discord.

Scripting API

Written 18 Nov 2026 · Requires Mammut 0.9.22+

This section lists everything a scene script can call: the scene itself, its elements, and the engine's managers. Each entry gives the full signature, its parameters, what it returns, how it behaves, and an example.

For how a script is put together and when its hooks run, see Scene Script. For a one-page overview, see Coding.

Reading an entry

Every entry starts with its signature:

SceneManager.SwitchScene(name: SceneName, fadeDuration = 1, fadeHold = 1): Promise<void>
  • name: SceneName is a parameter and its type.
  • fadeDuration = 1 is optional, and is 1 when you leave it out.
  • variant?: string (with a ?) is optional with no default. The entry says what happens without it.
  • number | string means either type is accepted.
  • The type after the closing bracket is what the call returns. void means nothing.
  • Promise<...> means the call finishes later. Inside an async method, await it to wait for it:
async onPlayPressed() {
  await SceneManager.LoadScene("level_1"); // waits until the scene's file has loaded
  SceneManager.SwitchScene("level_1");     // carries on without waiting for the fade
},

Project names

Some parameters take a name from your project. The script editor suggests the names that exist as you type:

Type Names of
SceneName Scenes
ChapterName Chapters
VariableName Project variables, from the Variables Manager
MusicName, AmbientName, SfxName, VoiceName Audio files in each audio folder

Names are the file name without its extension, in lower case, with spaces turned into underscores. Main Menu.mmsc is "main_menu". Any other text is accepted too, for names you build while the game runs.

The owner argument

Every Register method (on Store, Revealer, InputManager, AudioManager and Logger) takes an optional owner as its last argument. Pass this:

onStart() {
  Store.Register("lives", this.onLivesChanged, this);
},

onLivesChanged(lives: number) {
  this.dom.lives_label.textContent = `Lives: ${lives}`; // `this` is the scene, because it was passed as the owner
},

With an owner:

  • the handler is called with the owner as this, so scene methods work without .bind(this);
  • the handler is removed for you when the scene exits, so you don't need an Unregister in onExit();
  • registering the same handler with the same owner twice only adds it once.

Each of these managers also has UnregisterScene(owner), which removes everything that owner registered with it. The engine calls it when a scene exits.

Everything in this section

Name What it's for
Scene Script (this) Lifecycle hooks, this.dom, this.vars and sub-scenes
Element Helpers hide(), show(), setState() and the controls on animator, particle, Sprite Loop, Spine and checkbox nodes
Application Platform, quitting, fullscreen and opening links
Assets Looking up images, audio, characters and other files
AudioManager Music, ambient sound, sound effects, voices and volumes
DragDropManager Dragging elements onto drop zones
InputManager Keyboard and gamepad input
Logging log(), logWarning(), logError() and Logger
Revealer Revealing chapter text and reacting to its events
SaveManager Save slots, autosaves and game settings
SceneManager Switching, loading and attaching scenes
Store Project variables and the game state
Utilities delay(), invoke(), nextFrame() and appVersion

If your project replaces one of the engine's scripts (see Engine Script Overrides), that part of the engine works however your copy is written, and its page here may not match.