more than 1 custom song per section?

Need help with any SMBX game-related issues? Ask your questions here.
User avatar
mario610
Spiny
Spiny
Posts: 41
Joined: Tue Jan 07, 2014 3:44 pm

more than 1 custom song per section?

Postby mario610 » Tue Jun 09, 2020 11:23 pm

for like events to change the song from one custom one to the other, I remember you couldn't do that in SMBX1, and SMBX2 doesn't really seem like it, but I don't know entirely

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8520
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: more than 1 custom song per section?

Postby Enjl » Wed Jun 10, 2020 1:12 am

You can run an event that invokes lua code to change the music in a section. Here's an example, using the event "changemusic" to set the music to "bossfight.mp3". For different names, just replace changemusic with the name for your event, and the path to the music to what you named yours. OnEvent executes when ANY event is triggered, so by having multiple if-statements, you can do this multiple times for different events. The music path is relative to the level folder (folder with the name of the level file that is placed in the same folder as the level file).

Code: Select all

function onEvent(eventname)
	if eventname == "changemusic" then
		Audio.MusicChange(player.section, "bossfight.mp3")
	end
end
If you're unsure how to get a lua file to do this, you can find the button "level local (luna.lua)" in the "script"-menu option at the top of the editor.
The ABC of Creation
________________________________________________________
Image


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 23 guests