Audio System

The audio system handles music (background tracks) and sounds (effects).

TypeBehavior
MusicForms a playlist, plays random tracks in loop
SoundPlays files in sequence, once

Music

Music entries contain multiple track files. When you set music, the system:

StepWhat happens
1Shuffles all tracks randomly
2Plays the first track
3When track ends, plays next in shuffled order
4When all played, reshuffles and loops

Fade transition: When changing music, the current track fades out over ~1 second before the new music starts.

Playing Music

ActionDescription
{music: "music_id"}Play music by ID
{music: false}Use dungeon's default music

Example:

TriggerAction
Enter boss room{music: "boss_battle"}
Leave dungeon{music: "overworld"}

Default Dungeon Music

Set default music in the dungeon template config:

FieldDescription
musicMusic ID to play when entering this dungeon

When {music: false} is used, the system reverts to the dungeon's configured music.


Sounds

Sound entries can contain multiple files. When you play a sound, the system:

StepWhat happens
1Loads all sound files
2Plays first file
3When it ends, plays the next
4Continues until all files played

Sounds play in sequence (one after another), not simultaneously.

Playing Sounds

ActionDescription
{sound: "sound_id"}Play a sound effect
{sound: "sound1, sound2"}Play multiple sounds in sequence

Example:

TriggerAction
Player attacks{sound: "sword_slash"}
Door unlocks{sound: "key_turn, door_creak"}

Volume

Volume is controlled by user settings via Menu.


Methods

MethodDescription
game.setMusic(id)Play music by ID
game.setMusic(false)Use dungeon default music
game.playSounds(id)Play sound effect
game.playSounds([id1, id2])Play multiple sounds in sequence

Quick Reference

I want to...Do this
Play background music{music: "music_id"}
Play sound effect{sound: "sound_id"}
Chain sound effects{sound: "sound1, sound2, sound3"}
Reset to dungeon music{music: false}

Next Steps