Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // [Black Tulip] Play a Song - Basic Edition/Loop Song (AU)
- // Auryn Beorn
- /* You can modify and use this script in your own builds provided that you set permissions for
- next owner this way:
- no modify
- Either no copy or no transfer
- You are *not* allowed to sell or give away this script in any form
- The script should never have as permissions for next owner both copy and transfer
- */
- float timerTime = 9.5; // For samples cut to 9.5 seconds
- float volumeSound = 1.0; // Ranges from 0.0 to 1.0
- // You don't need to change anything below here
- integer currentSample;
- integer totalSamples;
- integer isMusicON;
- PlaySong()
- {
- if( llGetInventoryName(INVENTORY_SOUND, 0) == "" || llGetInventoryName(INVENTORY_SOUND, 1) == "")
- {
- llWhisper(PUBLIC_CHANNEL, "This script needs at least TWO sound samples to work.");
- return;
- }
- isMusicON = TRUE;
- llSetSoundQueueing(TRUE);
- totalSamples = llGetInventoryNumber(INVENTORY_SOUND);
- llPlaySound(llGetInventoryName(INVENTORY_SOUND, 0), volumeSound);
- llPreloadSound(llGetInventoryName(INVENTORY_SOUND, 1));
- llSetTimerEvent(5.0);
- currentSample = 1;
- }
- StopSong()
- {
- isMusicON = FALSE;
- llStopSound();
- llSetTimerEvent(0.0);
- }
- default
- {
- state_entry() { StopSong(); }
- on_rez(integer start_param) { StopSong(); }
- changed(integer change) { if(change & CHANGED_INVENTORY) StopSong(); }
- touch_start(integer total_number)
- {
- if(isMusicON) StopSong();
- else PlaySong();
- }
- timer()
- {
- if(isMusicON)
- {
- if(currentSample == 1)
- {
- llSetTimerEvent(timerTime);
- }
- llPlaySound(llGetInventoryName(INVENTORY_SOUND, currentSample), volumeSound);
- if(currentSample < (totalSamples - 1))
- {
- llPreloadSound(llGetInventoryName(INVENTORY_SOUND, currentSample + 1));
- }
- ++currentSample;
- if(currentSample >= totalSamples)
- {
- llSetTimerEvent(timerTime + 5.0);
- isMusicON = FALSE;
- }
- }
- else
- {
- StopSong();
- PlaySong();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement