PDA

View Full Version : Play Random Audio


devinw95
11-29-2015, 06:27 PM
I have a collection of audio clips that I would like to play in random orders to go along with my Alice program. I barely know where to start with this, right now I'm focusing on using random variables and arrays but I don't know how to use these to accomplish my task. Any input/help would be greatly appreciated, thank you!

sfunk
12-12-2015, 11:56 PM
Create a world variable. (Make it a number variable)

Create a world method appropriately named to what your task is.

Use a list function, have the number variable you created be assigned to a random number (use the min and max number to make a range of how many sound clips you are using)

then use if statements below that to find if the variable value == "randomly selected number" then "sound clip whatever" will play.

Use the else section of the if statements to further your conditions to test for the value of the variable.

There are multiple ways to have it loop while your world is running but one of the easiest is to put in a loop and place the method in a event "when the world begins"

MrMoke
12-13-2015, 01:40 PM
Or you can try something easier, and make less code work for you. Just add the single line where it's needed.

sfunk
12-15-2015, 05:12 PM
Or you can try something easier, and make less code work for you. Just add the single line where it's needed.

The only downside to not touching the program for close to a year, I barely remember any of it. But with any "language" there is always multiple ways to make something happen.