Touch Sound Toggle

From Second Life Wiki
Jump to navigation Jump to search

Created by Kira Komarov.

About

This is a very short script that I have been asked to created by MrChristian Luminos who told me that there is no such script available either on marketplace or the wiki. The script just toggles a sound on and off when an avatar touches the primitive the script is in.

Setup

  • Drop the script in a primitive of your choice.
  • Edit the script and modify the SOUND parameter at the top of the script to reference a sound UUID or a sound name if the sound-clip is in the same primitive this script will be placed in. The script triggers one of my sneezing recording from Wizardry and Steamworks.

Code

<lsl gremlin="Touch Sound Toggle"> ////////////////////////////////////////////////////////// // [K] Kira Komarov - 2011, License: GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html // // for legal details, rights of fair usage and // // the disclaimer and warranty conditions. // //////////////////////////////////////////////////////////

// Change this to either the NAME of a sound in the same primitive // as this script, OR the key of the sound to be played if it is not // in the same primitive as this script. string SOUND = "9fb1f482-5edf-1544-98c4-b8f86ea9ea26"; integer o = -1;

default {

   touch_start(integer total_number)
   {
       if(o = ~o) {
           llStopSound();
           return;
       }
       llLoopSound(SOUND, 1.0);
   }

} </lsl>

Hacks

The sound is played using llLoopSound and at volume 1.0 (maximum). However, you can replace those with say:

<lsl> llPlaySound(SOUND, 0.5); </lsl>

If you want the sound to be played just once and at half volume.