Here's an example of a room: there's a radio in it. You interact with it to change the background music. How could I use it to change the bg music more than once (eg: interact with radio, interact with it again, interact again, and change back to the original bg music)? Thanks, sorry if it's a little complicated, it was hard to explain ;D
Declare a variable called 'int current_bg_music' in the top of your room script.
Set it to whatever the starting bg_music is, for example, if you start with music 1:
int current_bg_music = 1;
Then, when you interact with the radio:
if (current_bg_music == 1) {
PlayMusic(2);
current_bg_music = 2;
}
else if (current_bg_music == 2) {
PlayMusic(3);
current_bg_music = 3;
}
else if (current_bg_music == 3) {
PlayMusic(4);
current_bg_music =4;
}
else if (current_bg_music == 4) {
PlayMusic(1);
current_bg_music =1;
}
This will play four songs by interacting with the radio. The first time will play song 2, second time, song 3, third time, song 4, and fourth time will start over with song 1.
Hope that helps
-Regards, Akumayo
How about:
EDIT:
int music[5];
music[1]=2;
music[2]=6;
music[3]=7;
music[4]=9;
current_bg_music++;
if (current_bg_music==4) current_bg_music=1;
PlayMusic(music[current_bg_music]);
;)
But it shouldn't be a problem to renumber the music files, though.
That would only work if the 'current_bg_music' had the exact same value as the playing music though. I didn't think he would really have all the possible bg music lined up as 1, 2, 3, 4, etc.
Thanks. I'll try that.
perhaps for more fun you can generate a random number and validate it with a specific sound file.
Yes, that too would be interesting, something like:
int last_music = 0;Ã, //declare a variable for use later
//repeatedly_excecute
int new_music = Random(10);Ã, //if you have 10 music files in total
if (new_music == 1 || new_music == 4 || new_music == 7) { //if you want musics 1, 4, or 7 to play
Ã, if (new_music != last_music) {Ã, //if the new music isn't the same as the music playing
Ã, Ã, PlayMusic(new_music);Ã, //play the music
Ã, Ã, last_music = new_music;Ã, //tell the script which music is playing
Ã, }
}