How to put custom sound effects and music lunalua problems

Need help with any SMBX game-related issues? Ask your questions here.
Levelmaker_123
Bob-Omb
Bob-Omb
Posts: 23
Joined: Fri Dec 08, 2023 1:46 pm
Pronouns: he
Contact:

How to put custom sound effects and music lunalua problems

Postby Levelmaker_123 » Wed Jul 31, 2024 7:11 pm

Alright,this may not be the last one but I really need help.
So first one is that the code that Just_Thomas provided is good and all and I'am pretty sure I screwed up again,but when I try to change custom music again (I just copied and pasted the code and changed the .mp 3 file) it shows this error
Original code:

Code: Select all

function onEvent(eventName)
	if(eventName == "musictrigger1") then
	Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
end
Error code:

Code: Select all

	main.lua:717: in function '__newindex'
	...Base Part III/Invading The Shroob Base Part III/luna.lua:15: in function 'codeFile'
	main.lua:742: in function 'loadCodeFile'
	main.lua:892: in function <main.lua:792>
	[C]: in function '__xpcall'
	main.lua:792: in function <main.lua:791>
Yeah,so this lunalua is for a cutscene and I don't know of I can only paste this once per level or what...
So the second one simpler but I need a way to put custom sound effects in game.
I recently switched from smbx 1.4.5 and there was a menu to do that so I didn't need to mess with the files.
But of there is a menu in smbx 2 for sound effects I didn't found it. I don't know if renaming the file should do it,but yeah,these are the problems.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9839
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: How to put custom sound effects and music lunalua problems

Postby Emral » Wed Jul 31, 2024 8:02 pm

That error log is incomplete. Could you share the whole error window you get, as a screenshot?

Levelmaker_123
Bob-Omb
Bob-Omb
Posts: 23
Joined: Fri Dec 08, 2023 1:46 pm
Pronouns: he
Contact:

Re: How to put custom sound effects and music lunalua problems

Postby Levelmaker_123 » Thu Aug 01, 2024 4:33 am

Image

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9839
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: How to put custom sound effects and music lunalua problems

Postby Emral » Thu Aug 01, 2024 6:20 am

Levekmaker_123 wrote:
Thu Aug 01, 2024 4:33 am
Image
Thank you!
The important bit in this one is the red text. It reads: "Overwritten handler onEvent in [path to your lua script]".
This means that you have 2 functions onEvent. This is a common mistake that can be easily fixed by moving the contents from one of the two into the other, then deleting the now-empty onEvent. Keep in mind that you can only have one function of each name in every script.

Levelmaker_123
Bob-Omb
Bob-Omb
Posts: 23
Joined: Fri Dec 08, 2023 1:46 pm
Pronouns: he
Contact:

Re: How to put custom sound effects and music lunalua problems

Postby Levelmaker_123 » Thu Aug 01, 2024 12:45 pm

Emral wrote:
Thu Aug 01, 2024 6:20 am
Levekmaker_123 wrote:
Thu Aug 01, 2024 4:33 am
Image
Thank you!
The important bit in this one is the red text. It reads: "Overwritten handler onEvent in [path to your lua script]".
This means that you have 2 functions onEvent. This is a common mistake that can be easily fixed by moving the contents from one of the two into the other, then deleting the now-empty onEvent. Keep in mind that you can only have one function of each name in every script.
I'am not too sure of I combined them correctly but here is what I did:

Code: Select all

function onEvent(eventName)
	if(eventName == "musictrigger1") then
	Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	if(eventName == "musictrigger2") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
end

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9839
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: How to put custom sound effects and music lunalua problems

Postby Emral » Thu Aug 01, 2024 6:10 pm

Levekmaker_123 wrote:
Thu Aug 01, 2024 12:45 pm
Emral wrote:
Thu Aug 01, 2024 6:20 am
Levekmaker_123 wrote:
Thu Aug 01, 2024 4:33 am
Image
Thank you!
The important bit in this one is the red text. It reads: "Overwritten handler onEvent in [path to your lua script]".
This means that you have 2 functions onEvent. This is a common mistake that can be easily fixed by moving the contents from one of the two into the other, then deleting the now-empty onEvent. Keep in mind that you can only have one function of each name in every script.
I'am not too sure of I combined them correctly but here is what I did:

Code: Select all

function onEvent(eventName)
	if(eventName == "musictrigger1") then
	Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	if(eventName == "musictrigger2") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
end
Very close! Every "if" needs an "elseif" or an "end". Try this:

Code: Select all

function onEvent(eventName)
	if(eventName == "musictrigger1") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	elseif(eventName == "musictrigger2") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
end
Or this:

Code: Select all

function onEvent(eventName)
	if(eventName == "musictrigger1") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
	if(eventName == "musictrigger2") then
		Audio.MusicChange(0, "Wario Land Shake It! OST - Bad Manor.ogg", 200)
	end
end
Either will do the trick. The difference is that in the top variant, the elseif will be automatically skipped if the if was correct.


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari