Audio Functions

These functions play music created in the Sound Editor.

play_music

play_music(index)

Play a music slot from the Sound Editor.

Parameters:

index (number) – Optional zero-based music slot index. 0 plays the first Sound Editor slot, 1 plays the second slot, and so on.

When index is omitted, the engine plays the default selected slot, which is currently slot 0.

function _init()
  play_music(0)  -- play Sound Editor slot 1
end

stop_music

stop_music()

Stop the current music playback.

if key_pressed(" ") then
  stop_music()
end