Advertisement
Guest User

Untitled

a guest
May 6th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // [Black Tulip] Play a Song - Basic Edition/Loop Song (AU)
  2. // Auryn Beorn
  3.  
  4. /*  You can modify and use this script in your own builds provided that you set permissions for
  5.     next owner this way:
  6.    
  7.         no modify
  8.         Either no copy or no transfer
  9.  
  10.     You are *not* allowed to sell or give away this script in any form
  11.     The script should never have as permissions for next owner both copy and transfer
  12. */
  13.  
  14.  
  15. float   timerTime = 9.5;    // For samples cut to 9.5 seconds
  16. float   volumeSound = 1.0;  // Ranges from 0.0 to 1.0
  17.  
  18.  
  19. // You don't need to change anything below here
  20.  
  21. integer currentSample;
  22. integer totalSamples;
  23. integer isMusicON;
  24.  
  25.  
  26. PlaySong()
  27. {
  28.     if( llGetInventoryName(INVENTORY_SOUND, 0) == "" || llGetInventoryName(INVENTORY_SOUND, 1) == "")
  29.     {
  30.         llWhisper(PUBLIC_CHANNEL, "This script needs at least TWO sound samples to work.");
  31.         return;
  32.     }
  33.  
  34.     isMusicON = TRUE;
  35.  
  36.     llSetSoundQueueing(TRUE);
  37.     totalSamples = llGetInventoryNumber(INVENTORY_SOUND);
  38.     llPlaySound(llGetInventoryName(INVENTORY_SOUND, 0), volumeSound);
  39.     llPreloadSound(llGetInventoryName(INVENTORY_SOUND, 1));
  40.     llSetTimerEvent(5.0);
  41.     currentSample = 1;
  42. }
  43.  
  44.  
  45. StopSong()
  46. {
  47.     isMusicON = FALSE;
  48.     llStopSound();
  49.     llSetTimerEvent(0.0);
  50. }
  51.  
  52.  
  53.  
  54. default
  55. {
  56.     state_entry()                   {   StopSong(); }    
  57.     on_rez(integer start_param)     {   StopSong(); }
  58.     changed(integer change)         {   if(change & CHANGED_INVENTORY) StopSong(); }
  59.    
  60.     touch_start(integer total_number)
  61.     {
  62.         if(isMusicON)       StopSong();
  63.         else                PlaySong();
  64.     }
  65.    
  66.     timer()
  67.     {
  68.         if(isMusicON)
  69.         {
  70.             if(currentSample == 1)
  71.             {
  72.                 llSetTimerEvent(timerTime);
  73.             }
  74.             llPlaySound(llGetInventoryName(INVENTORY_SOUND, currentSample), volumeSound);
  75.  
  76.             if(currentSample < (totalSamples - 1))
  77.             {
  78.                 llPreloadSound(llGetInventoryName(INVENTORY_SOUND, currentSample + 1));
  79.             }
  80.             ++currentSample;
  81.  
  82.             if(currentSample >= totalSamples)
  83.             {
  84.                 llSetTimerEvent(timerTime + 5.0);
  85.                 isMusicON = FALSE;
  86.             }
  87.         }
  88.         else
  89.         {
  90.             StopSong();
  91.             PlaySong();
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement