Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch on/off & play sound

Katanya Mistral
The Lonely Tigress
Join date: 6 Oct 2005
Posts: 87
04-28-2006 12:07
I am working on a gift for some friends and want them to be able to basically turn the object on and off. When on, part rotates and I want a sound to play. When off it is still and silent.
I have this rotation script so far:
CODE
default
{
touch_start(integer num_detected)
{
llTargetOmega(<0,0,1>, 1, 2);
}
}

How do I add in making it stop? Do I just use llLoupSound and llStopSound for the sound, or will that not work?
_____________________
Visit my website: Katanya.net
My SL site: Kitty's SL Adventures
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
04-28-2006 12:12
CODE
string sound = "name of sound in inventory";

default
{
state entry()
{
llStopSound(); // Silence!
llTargetOmega(<0,0,0>, 0, 0); // Be still!

}

touch_start(integer n)
{
state play; // State changes are cool.
}

on_rez(integer n)
{
llResetScript(); // Start from scratch to make all this predictable.
}
}

state play
{
state entry()
{
llLoopSound(sound, 1.0); // Make a joyful noise.
llTargetOmega(<0,0,1>, 1, 2); // Like a Dervish.

}

touch_start(integer n)
{
state default; // default state is off.
}

on_rez(integer n)
{
llResetScript(); // Start from scratch to make all this predictable.
}
}
_____________________
Katanya Mistral
The Lonely Tigress
Join date: 6 Oct 2005
Posts: 87
04-28-2006 12:14
Whoa, okay, that's more involved than I would have figured out.

Thanks so much for posting that Jillian, and thank you for commenting it so I understand what it does.
_____________________
Visit my website: Katanya.net
My SL site: Kitty's SL Adventures
Katanya Mistral
The Lonely Tigress
Join date: 6 Oct 2005
Posts: 87
04-28-2006 12:36
Okay, unfortunately didn't realize it until it was upload time, but I had to break the sound down into 2 files. Could I just make the string sound1 + sound2?


Edit: Nope, guess string sound = "sound1" + "sound2"; won't work; keep getting a syntax error.
_____________________
Visit my website: Katanya.net
My SL site: Kitty's SL Adventures