Hi,
I've searched but I can't seem to find what I'm looking for in the archives. I have 10 sound files that i want to have play randomly (without being touched). Not one right after the other, every minute or 2.
thanks guys!
These forums are CLOSED. Please visit the new forums HERE
Looking for a random sounds player script - not triggered by touch |
|
|
Ingrid Ingersoll
Archived
Join date: 10 Aug 2004
Posts: 4,601
|
08-25-2006 12:23
Hi,
I've searched but I can't seem to find what I'm looking for in the archives. I have 10 sound files that i want to have play randomly (without being touched). Not one right after the other, every minute or 2. thanks guys! _____________________
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
08-25-2006 14:29
Try this off the top of my head:
CODE
|
|
Ingrid Ingersoll
Archived
Join date: 10 Aug 2004
Posts: 4,601
|
08-25-2006 16:29
Thanks Dote!
I'm getting (9,6 ERROR name not defined within scope. is this fixable? _____________________
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-25-2006 16:32
can change the top 4 variable values if you want.
CODE float max_time = 120.0; //In Seconds _____________________
|
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
08-25-2006 16:35
oops, he beat me to it
, ah well, the only differences between his and mine is mine allows for random volumes, and checks to see if there are no sounds in the contents. If you didn't have any sounds in the contents with his that might have given that error... maybe, doesn't sound right but I don't see any other problem._____________________
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
08-25-2006 16:51
Thanks Dote! I'm getting (9,6 ERROR name not defined within scope. is this fixable? And yes, the check in Rickard's version is a smart check to prevent potential script spam if no sounds are found in inventory. |
|
Ingrid Ingersoll
Archived
Join date: 10 Aug 2004
Posts: 4,601
|
08-25-2006 19:55
Awesome! thanks guys! I'm keeping both!
_____________________
|
|
Tommy Sikorsky
Registered User
Join date: 7 Oct 2006
Posts: 5
|
Random Sound Player Script
11-21-2006 23:11
Hi,
Used the following script to play random sounds. Works except it only plays one sound. I placed about 8 or so sound files in the objects inventory. Can anyone help me with a reason this won't work? Thank you! PHP Code: float max_time = 120.0; //In Seconds float min_time = 60.0; //In Seconds float max_volume = 1.0; //1.0 is full volume float min_volume = 0.5; //0.01 is the lowest allowed default { state_entry() { if (min_time < 0.1) min_time = 0.1; if (max_time < min_time) max_time = min_time; if (min_volume < 0.01) min_volume = 0.01; if (max_volume < min_volume) max_volume = min_volume; llSetTimerEvent(1.0); } timer() { llSetTimerEvent(llFrand(max_time - min_time) + min_time); integer num_sounds = llGetInventoryNumber(INVENTORY_SOUND); if (num_sounds > 0) { string inventory_sound = llGetInventoryName(INVENTORY_SOUND, llFloor((float)llGetInventoryNumber(INVENTORY_SOUN D) - 0.001)); llTriggerSound(inventory_sound, llFrand(llFrand(max_volume - min_volume) + min_volume)); } } } |
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-22-2006 01:00
Hi, Used the following script to play random sounds. Works except it only plays one sound. I placed about 8 or so sound files in the objects inventory. Can anyone help me with a reason this won't work? Thank you! Mainly because you are only ever asking it to play one sound! Your code to get the sound name isnt random, its always returning one less than max. llFloor returns the nearest integer to the value entered. (Personally i'd rewrite the whole thing but thats just me!) try this instead :- CODE
|
|
Tommy Sikorsky
Registered User
Join date: 7 Oct 2006
Posts: 5
|
Random Sounds Player Script
11-24-2006 12:36
Hey Newgate,
Thank you - your suggestions worked great. I am just trying to learn scripts and was looking at that statement with some suspicion but wasn't sure what to do about it. Thank you again. Tommy |
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-24-2006 12:58
Hey Newgate, Thank you - your suggestions worked great. I am just trying to learn scripts and was looking at that statement with some suspicion but wasn't sure what to do about it. Thank you again. Tommy Your Welcome. |