Jump to content

Shuffle or randomize which sound will play?


maeglutz
 Share

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

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

Recommended Posts

Hello ^^ I'm working on a typer and I'd like for the sounds to be randomized, so that it's not the same one everytime. Unfortunately, I don't understand how to put in multiple, let alone make them shuffle.

 

default
{
    state_entry()
    {
       llSetTimerEvent(1);
    }
  
timer() {
                    if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING) 
       
                    {
                 llLoopSound("Typie", 0.2);  
                    }
              
                else 
               {
                llStopSound();
                 }
        }
}

 Here's what I have so far ^^

Link to comment
Share on other sites

first , get all your sounds in a list in state entry.

 next count the items in your list of sounds and choose a random numbered one to play.

 

list sounds;
default
{
    state_entry()
    {   integer count;
        string name;
        while ( (name = llGetInventoryName(INVENTORY_SOUND, count))  )
        { sounds += name;
          ++count;   
        }
         llSetTimerEvent(0.2);
    }
   timer()
   { integer len = llGetListLength(sounds) - 1;
     if (llGetAgentInfo(llGetOwner()) & AGENT_TYPING)
     {   integer place = llRound(  llFrand(len)    );
         llLoopSound( llGetInventoryName(INVENTORY_SOUND, place), 0.2);  
       
     }              
      else
     {   llStopSound();
     }
   }
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3350 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...