Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How do I add an on/off switch to looped sound script?

Justus Elytis
Registered User
Join date: 16 Dec 2005
Posts: 10
03-16-2006 18:52
I know next to nothing about scripting, I just tweak them a little. I've done a forum search, but can't find the info I need.

I am making a fountain that I would like to be able to turn the sound on and off by clicking it- How do I do that? I am using the freebie script, 'single sound' that loops the sound.

Any aid would be appreciated.
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
03-16-2006 19:09
Have your sound event listen to a channel, then your switch should speak on touch through the channel.


I do not have the code on hand...sorry. But that's the idea.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
03-16-2006 19:17
CODE

string soundFileName = "soundFile"; // Change this to the name of the sound clip
float volume = 0.5; // Change this to the volume the clip will play at

default
{
state_entry()
{
llLoopSound(soundFileName, volume);
}

touch_start(integer num)
{
state off;
}
}

state off
{
state_entry()
{
llStopSound();
}

touch_start(integer num)
{
state default;
}
}
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
03-16-2006 19:26
:p What Ziggy said.
Justus Elytis
Registered User
Join date: 16 Dec 2005
Posts: 10
03-16-2006 19:50
TY Ziggy, I will try that!