Random songs?

Started by Candle, Thu 27/10/2005 08:09:21

Previous topic - Next topic

Candle

I haven't tried it yet but was wondering if you can do them like you would do a random message or numbers?
So everytime they went into a room something else would play.

esper

I've seen a couple other solved posts on this in the past couple days. I'm busy right now, or I'd find them for you, but it shouldn't be too hard.

My point for taking this post, though, was to ask why. If there's a good and logical reason, that's cool, but be careful that it doesn't sound disjointed to the player. Aesthetic value is one of the factors that keeps people playing.
This Space Left Blank Intentionally.

Candle

#2
Well I was thinking for this main room the two chars will be in and and a lot of coming and going so maybe have diff tunes play.

EDIT:
This worked.

int blah = Random(3);
if (blah==0)PlayMusic(1);
else if (blah==1) PlayMusic(2);
else if (blah==2) PlayMusic(3);
else if (blah==3) PlayMusic(4); 

esper

Actually, I seem to be full of crap. I just went looking for you and couldn't find anything, althoughI thought Mats Berglinn had a post about random music a week or so ago. I know how to do it, but I'm really busy right now or I'd prolly whp you up some code, but I'm sure someone wil come along any second now. It is pretty easy, if I remember correctly, so don't worry.
This Space Left Blank Intentionally.

Ashen

If, as in the example above, all the music files are grouped together, you could probably use:

Code: ags

int blah = Random(3) + 1; // Replace 1 with the lowest number you want to play (e.g. '+ 10' to play 10, 11, 12 or 13).
PlayMusic(blah); 


No real difference, just saves you writing out a long list of else if's.
I know what you're thinking ... Don't think that.

Candle


Akumayo

Using the Ultimate Randoms module, the files don't have to be in order, and you could run something like:
PlayMusic(RandomOfX(4, 3, 7, 11, 1));
Would play MUSIC3, MUSIC7, MUSIC11, or MUSIC1
"Power is not a means - it is an end."

Candle

Thanks for pointing that out.

SMF spam blocked by CleanTalk