Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // set debug mode to TRUE or FALSE
- #define DEBUG
- // commands to send to play engine
- #define SONG_PLAY 0x00000001 // flag to start the song playing
- #define SONG_STOP 0x00000002 // flag to stop the current song playing
- #define SONG_VOL 0x00000004 // flag to indicate a change / or the
- // volume level
- #define SONG_END 0x00000008 // End of playing song
- // debugging command
- DS (string sayd)
- {
- #ifdef DEBUG
- string scriptName = llGetScriptName();
- llOwnerSay(scriptName + ": " + sayd);
- #endif
- }
- // golbal variable
- list currentSong_info; // list of current song info and uuid for wav files.
- float volume; // sound volume level
- integer listPlace; // place in the currentSong_list that is playing.
- default
- {
- state_entry()
- {
- DS("Free Memory: " + (string) llGetFreeMemory());
- }
- link_message(integer sender_num, integer num, string str, key id)
- {
- DS("link_message : " + str);
- switch (num)
- {
- case (SONG_PLAY):
- {
- currentSong_info = llCSV2List(str);
- DS(llList2String(currentSong_info, 3));
- llPlaySound(llList2String(currentSong_info, 3), volume);
- llSetTimerEvent((llList2Float(currentSong_info, 2) - 1));
- llSoundPreload(llList2String(currentSong_info, (3 + 1)));
- listPlace = 3;
- break;
- }
- case (SONG_VOL):
- {
- volume = (float) str;
- break;
- }
- case (SONG_STOP):
- {
- #ifdef DEBUG
- llSay(888, "STOP");
- #endif
- llSetTimerEvent(0);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- timer()
- {
- DS("Timer");
- if(++listPlace < llGetListLength(currentSong_info))
- {
- #ifdef DEBUG
- llSay(888, "RESET");
- #endif
- DS("Playing UUID " + llList2String(currentSong_info, listPlace));
- llPlaySound(llList2String(currentSong_info, listPlace), volume);
- if(!(listPlace <= llGetListLength(currentSong_info)))
- llSoundPreload(llList2String(currentSong_info, (listPlace + 1)));
- }
- else
- {
- #ifdef DEBUG
- llSay(888, "STOP");
- #endif
- DS("end of song");
- llMessageLinked(LINK_SET, SONG_END, "","");
- llSetTimerEvent(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement