spumoni

Warper
Member
Joined
May 26, 2023
Messages
2
Reaction score
0
First Language
english
Primarily Uses
RMVXA
Hi all, I'm trying to have a sound effect play at random intervals in the background of one of my maps. I am so lost, I've tried the random control variables and using ruby to script and still can't find out how to use the random variable as a # of frames for wait time. Any help or direction is greatly appreciated
 

TheAM-Dol

Randomly Generated User Name
Veteran
Joined
Feb 26, 2022
Messages
620
Reaction score
924
First Language
English
Primarily Uses
RMMV
You could create a timer loop in a parallel event either on the map or a common event if you plan to use it often on multiple different maps.
Use a control variable. Let's call this variable "Timer"
Control variable, random 60 ~ 300.
//this is picking a random amount of time which our loop below will begin counting down from.
Create a loop.
Loop:
If "Timer" is < 0
PLAY SFX
break loop
//above is used to determine what happens when the timer has reached the end
Else
"Timer" - 1
Wait 1 frame
//this is used to count down the timer. It's important to have a wait frame to reduce the amount of cycles and processing the game needs to do for the event. In my opinion, this is a non-critical event, so you may want to use a longer wait time. 60 is good, since 60 frames will be 1 second. If you change the wait to 60, be sure to adjust the Timer variables random value range (otherwise if it rolls a 300, that means it will be 300 seconds until it triggers the sound)
End
Loop end

*on my phone, sorry for the lack of screen shots and weird formatting. If no one replies by the time I get home, I'll make a post that more clearly shows what I'm talking about if you don't understand.
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
45,990
Reaction score
16,777
First Language
English
Primarily Uses
RMMV
@spumoni are you using VX or VX Ace? Your profile says you're using Ace, but you posted in the support forum for VX.
 

Latest Threads

Latest Profile Posts

dV9O5Z.png


Continuing our countdown with Capsule Monster #14 Plug-Go! Plug-Go was originally meant to be the design of a gameboy game I wanted to make that was inspired by Megaman Battle Network! While that hasn’t worked out I’m happy I was able to recycle his design!
uApM6Gk.png

X6lGcLM.png

Took some time to pretty up the maps too.
Size Comparison.gif
12 hour little challenge for myself to do a big'ish enemy. Released for MV/MZ, working on my streamline one for later as I love the four frames over three. Spins a whole lot better I think.
Okay last one for now, it's time to go treat myself to some Zelda!

UPDATED- I've completely ripped off Sword of Mana right here lol
It seems like the imgur images are working again! ;3

Forum statistics

Threads
131,505
Messages
1,220,347
Members
173,224
Latest member
ZecaVn
Top