Table of Contents

About

This script was tested and works on OpenSim version 0.7.4!

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

Code

touch_sound_toggle.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, 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);
    }
}

Hacks

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

llPlaySound(SOUND, .5);

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