Advertisement
kopilo

LuL - SoundBox

Jan 21st, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer numSounds;
  2. integer currSound;
  3. //settext is for debug
  4. regSound() {
  5.     integer i;
  6.     numSounds = llGetInventoryNumber(INVENTORY_SOUND);
  7.     for(i=0;i <= numSounds;i++) {
  8.         llPreloadSound(llGetInventoryName(INVENTORY_SOUND,i));
  9.         llSetText("preloading " + (string) i + " of " + (string)numSounds, <1,1,1>,1);
  10.     }
  11. }
  12.  
  13. sleepTimer() {
  14.     while(TRUE) {
  15.     if(currSound < numSounds) {
  16.         currSound++;
  17.         llPlaySound(llGetInventoryName(INVENTORY_SOUND,currSound), 1);
  18.         llSetText("Playing " + (string)currSound + " of " + (string)numSounds, <1,1,1>,1 );
  19.     }
  20.     else {
  21.         restart();
  22.     }
  23.         llSleep(10);
  24.     }
  25. }
  26.  
  27. start() {
  28.     //no sound queing because opensim doesn't support it, so it sounds like crap
  29.     currSound = 0;
  30.     string tm = llGetInventoryName(INVENTORY_SOUND,currSound);
  31.     llSetText("Playing " + (string)currSound + " of " + (string)numSounds, <1,1,1>,1 );
  32.     sleepTimer();
  33. }
  34.  
  35. restart() {
  36.     currSound = 0;
  37.     llPlaySound(llGetInventoryName(INVENTORY_SOUND,currSound), 1);
  38. }
  39.  
  40.  
  41.  
  42. default
  43. {
  44.     state_entry()
  45.     {
  46.         regSound();
  47.         start();
  48.        
  49.     }
  50.     changed(integer p) {
  51.         if(p & CHANGED_INVENTORY) {
  52.             regSound();
  53.             restart();
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement