Add audio¶
Play a sound from Lua¶
Or use the global Audio namespace:
Play music¶
Stop it with Audio.stopMusic("assets/music.mp3") or Audio.stopAllMusic().
Settings screen¶
The settings template (UI/lua/templates/settings.lua) always draws VOL -, VOL +, Mute music, and Mute effects above any extra rows.
VOL -andVOL +add or subtract0.1on eachAudioSource, clamped to0..1. Sources keep their own levels.Mute musicsets every source withisMusicto0. Unchecking it writes the volume saved when that source was muted.Mute effectsdoes the same for sources withisMusic == false.- A category with no sources stays as it is. While a mute stays checked, each draw of the settings screen keeps that category at
0, including a source that appears while the screen is open. - The editor preview draws these rows and does not write volume into the scene.
Audio.playSoundandAudio.playMusicare notAudioSourcecomponents, so these rows do not change them.
Tips¶
- Sound effects are decoded into RAM and can overlap many times.
- Music is streamed from disk with one playhead per asset.
- Set
loop = truefor background tracks. shouldPlayis cleared byAudioSystemafter handling; set it once, not every frame.- Bundled ids are relative file names (
laser.wav, notassets/laser.wav).
See Engine → Audio and Lua → Audio.