Jump to content

Error: Name not defined within scope Grrrr


Existential Conundrum
 Share

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

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

Recommended Posts

I have a couple sounds I'd like randomize play. On state entry is fine. it's just to enhance thunder and rain that is audio silent. I found this:

http://wiki.secondlife.com/wiki/Script:Random_Sounds

But, I keep getting an error even if I type the names of the sounds:

soundnames = [Thunder-03-01, Rain-Thunder-01, Rain-Thunder-02, Rain-Thunder-03];

not sure if my syntax is wrong or I'm typing the wrong thing or what. Blank gets same error. I have no idea if there is a better way. Please and thank you for help.

Link to comment
Share on other sites

Thank you for replying. It's still giving me the same error. What am I doing wrong? 

2 hours ago, Rolig Loon said:

You forgot the quotes. Those are string constants.

float MinimumSeconds = 10.0; float MaximumSeconds = 30.0; float volume = 0.5; // How loud? Between 0 and 1
integer sounds = 4; // # sounds in inventory list soundnames; // names of sounds in inventory
LoadSounds() {

   soundnames = ["Thunder-03-01", "Rain-Thunder-01", "Rain-Thunder-02", "Rain-Thunder-03"];
   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();
       }
   }
}

Link to comment
Share on other sites

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