How to put custom music with events

Need help with any SMBX game-related issues? Ask your questions here.
Levekmaker_123
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Fri Dec 08, 2023 1:46 pm
Pronouns: he

How to put custom music with events

Postby Levekmaker_123 » Fri May 10, 2024 12:16 pm

I know it's my second one but I kinda need to know. And I don't wanna learn lunalua.

So is there a way to put custom music into levels with events? There is only a "Custom" button at the events,but it just restarts the custom music,and there isn't any "Music file" stuff like in the section settings.

Just_Thomas
Spike
Spike
Posts: 296
Joined: Sat Dec 16, 2023 3:32 am
Pronouns: he/him

Re: How to put custom music with events

Postby Just_Thomas » Fri May 10, 2024 3:37 pm

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:
Image

Levekmaker_123
Cheep-Cheep
Cheep-Cheep
Posts: 10
Joined: Fri Dec 08, 2023 1:46 pm
Pronouns: he

Re: How to put custom music with events

Postby Levekmaker_123 » Sat May 11, 2024 4:48 am

Thanks,it works!


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari