Jump to content

Random Sound Script help


Reymundo
 Share

You are about to reply to a thread that has been inactive for 2787 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I was initially as confused as Rolig, but I have a theory. The LSL editor highlights type-definitions in orange, and maybe it got confused and painted your entire script that color. Or it thought the entire script was a string and printed in red. I'm guessing you copied and pasted the entire example web page into the script window, which won't work. 

Here's the script, cleaned up...

float MinimumSeconds = 10.0; // Minimum time between successive sounds (seconds)float MaximumSeconds = 30.0; // Maximum time between successive sounds (seconds)float volume = 0.5; // How loud? Between 0 and 1.integer sounds = 0; // # sounds in inventorylist soundnames;
LoadSounds() { soundnames = []; sounds = llGetInventoryNumber( INVENTORY_SOUND ); integer n; for ( n=0; n < sounds; ++n ) { soundnames += llGetInventoryName( INVENTORY_SOUND, n ); }} default { state_entry() { LoadSounds(); if ( sounds > 0 ) llSetTimerEvent( 0.1 ); else llOwnerSay("No sounds."); } timer() { integer random = (integer) llFrand ( sounds ); string sound = llList2String( soundnames, random ); llTriggerSound( sound, volume ); llSetTimerEvent( MinimumSeconds + (llFrand( MaximumSeconds - MinimumSeconds)) ); } changed (integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } }}

 If that's not what you meant, I remain as confused as Rolig.

Link to comment
Share on other sites

Look at the timer event.  When it is triggered, the script chooses a sound and playes it, then calculates the random time for triggereing the timer event next time.  It's exactly what you would expect a timer event to do:  trigger, do something, wait, trigger, do something else, wait, wash, rinse, repeat ....

Link to comment
Share on other sites

Well, if you play a sound that takes a full 10 seconds to play, then yes, the next one might be triggered almost immediately after the first one ends.  The timer event has no idea how long your sound files are.  All it's doing is starting one when you tell it to. That's what timer events do.  If you are really using long files, I'd suggest monkeying with the minimum and maximum times to create more space between them.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2787 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...