User:Toady Nakamura/Sound Looper

From Second Life Wiki
Jump to navigation Jump to search

There are three ways to call sound files in SL.

  • By having the script find the file in its inventory
  • By using the exact file name with the sound in inventory
  • By using the UUID identifier number. This does not require the sound to be in the prim.

All three methods are included below, two of them are "//" commented out. To activate, remove the comment slashes from the line you'd like to use. Be sure the other two are commented out or removed in your final product !!

 
float vol = 0.90;  // Volume can be changed to any number between 0.0 (silent) and 1.0 (full).

default
{
    state_entry()
    {
        llStopSound(); // turns off any previous sound
        llSleep(0.2);  // delay to be sure sound is off
        
   //--> With the sound file in the prim, use either of these methods
        
        llLoopSound(llGetInventoryName(INVENTORY_SOUND, 0), vol);  

        //llLoopSound("Put Inventory Name Here & Sound In Prim", vol);
        
   //--> Or use UUID key number and do not put the sound file in the prim.

        //llLoopSound("UUID ID #", vol);
    }
}

Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura