Emral wrote: ↑Sun Apr 07, 2024 7:54 pm
Change music from Custom A to Custom B in event:
Code: Select all
function onEvent(eventName)
if eventName == "CustomMusicB" then
Audio.MusicChange(player.section, "NewCustomMusic.ogg") -- NewCustomMusic.ogg assumed to be in the episode folder. If it's in a subfolder, specify a path.
end
end
Music.ini is only ever necessary if we're talking world map music.
The
SDL Stream music functions like Audio.MusicOpen should not be conflated with the common functions that utilize SMBX's internal music playback system.
Do you get that?
In this case "CustomMusicB" is the name of a SMBX2 vanilla event, so the ones you set up in the editor.
Try that for yourself:
Code: Select all
function onEvent(eventName)
if(eventName == "musictrigger1") then
Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
end
end
In the editor.
Script -> LunaLua Script -> Level Local
pasted that code (under "try that for yourself")
create a new classic event (where that yellow stopwatch is) and name it: musictrigger1
Either copy the ogg file from the demo stages or take something else.
Here - once you trigger "musictrigger1" section 0 now plays that song with a small delay of 200 ms.
You can setup as many of these as you like.
instead of "eventName" you could also use something else like "YourMum", "IHateTrains" etc.
I can not give you a proper explanation for this, as I am not a coder myself, but it has something to do with "reserve some kind of space".
https://docs.codehaus.moe/#/reference/audio
As screenshot: