Need help with any SMBX game-related issues? Ask your questions here.
|
|
|
|
-
DeepBlue PacificWaves
- Goomba

- Posts: 2
- Joined: Sun May 29, 2022 1:13 am
- Pronouns: He/Him
Postby DeepBlue PacificWaves » Tue Jun 14, 2022 9:40 pm
Hello there. I recently discovered SMBX2 and I'm having some fun discovering how this tool works. I'm even thinking of making a classic-inspired adventure world, just to show off a little to my brother. However, there is something that I don't know how to implement yet.
In the official Mario games, whenever the timer dropped down below 100, a jingle played to alert the player, and the music's pace suddenly got faster. I see that the jingle play as expected, but the music remains much of the same.
Is there a way to make the music goes faster after the the timer drop below a certain value? If there is, how can I implement it?
In advance, I thank you fir reading my beginner's question X'D
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo

- Posts: 1442
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Wed Jun 15, 2022 5:46 am
DeepBlue PacificWaves wrote: ↑Tue Jun 14, 2022 9:40 pm
Is there a way to make the music goes faster after the the timer drop below a certain value? If there is, how can I implement it?
In advance, I thank you fir reading my beginner's question X'D
Unlike the original games, the music in SMBX2 is not usually a MIDI sequence that can easily be just sped up, which is why that doesn't happen. However, it is possible to do so manually by making a copy of the music, manually speeding it up in your audio program of choice (such as Audacity), and then using Lua to check the value of the timer and use Audio.MusicChange to swap the music for the sped up version.
|
|
|
|
|
|
|
|
|
-
DeepBlue PacificWaves
- Goomba

- Posts: 2
- Joined: Sun May 29, 2022 1:13 am
- Pronouns: He/Him
Postby DeepBlue PacificWaves » Wed Jun 15, 2022 9:12 am
However, it is possible to do so manually by making a copy of the music, manually speeding it up in your audio program of choice (such as Audacity), and then using Lua to check the value of the timer and use Audio.MusicChange to swap the music for the sped up version.
Yeah, I figured that much out. I'm just having trouble with the code part. I tried using the following code I'm my lua level file:
Code: Select all function onStart()
Timer.activate(115)
if Timer.getValue(Timer) == (99) then
Audio.MusicChange("Hurry Up.ogg")
end
end
But it didn't work as w..., well, it didn't worked at all. Am I coding something wrong? Any tips you can give me to make it work?
Btw, thanks for answering so quickly =D
|
|
|
|
|
|
|
|
|
-
deice
- Buster Beetle

- Posts: 441
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Wed Jun 15, 2022 9:22 am
DeepBlue PacificWaves wrote: ↑Wed Jun 15, 2022 9:12 am
Code: Select all function onStart()
Timer.activate(115)
if Timer.getValue(Timer) == (99) then
Audio.MusicChange("Hurry Up.ogg")
end
end
But it didn't work as w..., well, it didn't worked at all. Am I coding something wrong? Any tips you can give me to make it work?
in the code above, the timer check will only run once at the start of the level. also, the MusicChange() call needs to specify a section.
try this code out:
Code: Select all local musicChanged
function onStart()
Timer.activate(115)
musicChanged = false
end
function onTick()
if (Timer.getValue(Timer) == 99 and not musicChanged) then
Audio.MusicChange(player.section, "Hurry Up.ogg")
musicChanged = true
end
end
also, a few additional notes:
- passing -1 instead of player.section will result in that music being set for every section
- if you want to use different music depending on the section, you have to iterate through each and call MusicChange() with the corresponding audio file
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo

- Posts: 1442
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Wed Jun 15, 2022 1:28 pm
Also: The addition of the argument in Timer.getValue(Timer) is meaningless. You just need Timer.getTimer()
The code deice posted actually isn't the best way to handle this anyway. You'd be better off using the raw timer value than the display value, like so:
Code: Select all function onTick()
if Timer.get() == math.ceil(99*Timer.getSecondLength()) then
Audio.MusicChange(-1, "Hurry Up.ogg")
end
end
|
|
|
|
|
|
|
|
|
-
deice
- Buster Beetle

- Posts: 441
- Joined: Fri Jul 23, 2021 7:35 am
Postby deice » Wed Jun 15, 2022 1:46 pm
Hoeloe wrote: ↑Wed Jun 15, 2022 1:28 pm
You'd be better off using the raw timer value than the display value
that's true. i had never actually used timer.lua before so i didn't know about getSecondLength() and was just going off what the OP had in their code, thanks for the correction
|
|
|
|
|
|
|
|
|
-
Hoeloe
- Foo

- Posts: 1442
- Joined: Sat Oct 03, 2015 6:18 pm
- Flair: The Codehaus Girl
- Pronouns: she/her
Postby Hoeloe » Thu Jun 16, 2022 9:26 am
deice wrote: ↑Wed Jun 15, 2022 1:46 pm
Hoeloe wrote: ↑Wed Jun 15, 2022 1:28 pm
You'd be better off using the raw timer value than the display value
that's true. i had never actually used timer.lua before so i didn't know about getSecondLength() and was just going off what the OP had in their code, thanks for the correction
There's also setSecondLength(frames). By default it's set to... well, one second, but it's configurable so that the timers from older Mario games can be reproduced, which ticked down faster than 1 second at a time.
|
|
|
|
|
Return to “Help and Support”
Users browsing this forum: No registered users and 1 guest
|