Simple random jukebox?

Started by , Sat 14/04/2007 21:05:01

Previous topic - Next topic

m0ds

Hello. I have a small question about randomising & repeating midi music in AGS. The code I'm currently using in rep_execute is;

Quoteint jukebox2=Random(29);
// jukebox
if(IsMusicPlaying()==0) {
PlayMusic(jukebox2);
}

Choosing from 29 tunes. I need it to reset every time the game is restarted (with F9). At the moment, the game has to be shut down completely and restarted again before it randomizes. On the very first try it did actually work, but never again after that... lol! Also, I need it to reset and select a new tune when the previous tune ends. That's a bit complex for me! Also, I need it to NOT bother looking for music 0, because I don't think that can exist. But saying that, it hasn't crashed on me yet.

Any help appreciated!

Ashen

#1
For the first part: Forum Search. Been asked a few times before, Gilbot's seems to be the best answer.

Second part - what's your 'repeat music' setting (SetMusicRepeat)?
Quote from: The Manual
If you are using the Repeat Music option, this will always return 1 since the music will loop round when it finishes.
So, is it possible the condition is just never getting called?

For the last part, what if you try:
Code: ags

int jukebox2 = Random(28)+1;

That way, the selection will be between 1 and 29, not 0 and 29.
I know what you're thinking ... Don't think that.

m0ds

Thanks. "Randomizing numbers when restarting game" would've been the last thing I'd have searched for personally, jukebox, random music & something else I tried revealed nothing. Anyway I'll try the suggestions here.

SMF spam blocked by CleanTalk