Advertisement
Madi_Perth

Untitled

Jan 8th, 2024
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Linden Scripting 2.39 KB | Source Code | 0 0
  1. // set debug mode to TRUE or FALSE
  2. #define DEBUG
  3.  
  4. // commands to send to play engine
  5. #define SONG_PLAY   0x00000001  // flag to start the song playing
  6. #define SONG_STOP   0x00000002  // flag to stop the current song playing
  7. #define SONG_VOL    0x00000004  // flag to indicate a change / or the
  8.                                 // volume level
  9. #define SONG_END    0x00000008  // End of playing song
  10.  
  11. // debugging command
  12. DS (string sayd)
  13. {
  14. #ifdef DEBUG
  15.    string scriptName = llGetScriptName();
  16.    llOwnerSay(scriptName + ": " + sayd);
  17. #endif
  18. }
  19.  
  20. // golbal variable
  21. list  currentSong_info; // list of current song info and uuid for wav files.
  22. float volume;           // sound volume level
  23.  
  24. integer  listPlace;     // place in the currentSong_list that is playing.
  25.  
  26. default
  27. {
  28.    state_entry()
  29.    {
  30.       DS("Free Memory: " + (string) llGetFreeMemory());
  31.    }
  32.  
  33.    link_message(integer sender_num, integer num, string str, key id)
  34.    {
  35.       DS("link_message : " + str);
  36.  
  37.       switch (num)
  38.       {
  39.          case (SONG_PLAY):
  40.          {
  41.             currentSong_info = llCSV2List(str);
  42.             DS(llList2String(currentSong_info, 3));
  43.  
  44.             llPlaySound(llList2String(currentSong_info, 3), volume);
  45.             llSetTimerEvent((llList2Float(currentSong_info, 2) - 1));
  46.  
  47.             llSoundPreload(llList2String(currentSong_info, (3 + 1)));
  48.             listPlace = 3;
  49.             break;
  50.          }
  51.          case (SONG_VOL):
  52.          {
  53.             volume = (float) str;
  54.             break;
  55.          }
  56.          case (SONG_STOP):
  57.          {
  58.  #ifdef DEBUG
  59.    llSay(888, "STOP");
  60. #endif
  61.             llSetTimerEvent(0);
  62.             break;
  63.          }
  64.          default:
  65.          {
  66.             break;
  67.          }
  68.       }
  69.  
  70.    }
  71.  
  72.    timer()
  73.    {
  74.       DS("Timer");
  75.       if(++listPlace < llGetListLength(currentSong_info))
  76.       {
  77. #ifdef DEBUG
  78.    llSay(888, "RESET");
  79. #endif
  80.          DS("Playing UUID " + llList2String(currentSong_info, listPlace));
  81.  
  82.          llPlaySound(llList2String(currentSong_info, listPlace), volume);
  83.          if(!(listPlace <= llGetListLength(currentSong_info)))
  84.             llSoundPreload(llList2String(currentSong_info, (listPlace + 1)));
  85.       }
  86.       else
  87.       {
  88. #ifdef DEBUG
  89.    llSay(888, "STOP");
  90. #endif
  91.          DS("end of song");
  92.          llMessageLinked(LINK_SET, SONG_END, "","");
  93.          llSetTimerEvent(0);
  94.       }
  95.    }
  96. }
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement