Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

A little help needed with simple sound script

Katelyn Brock
Registered User
Join date: 15 Jun 2006
Posts: 5
07-31-2006 16:42
Hello everyone !

Despite all of the wonderful help here in the forum, as a new person to scripting I have been unable to find a command to help me with my script.

I'm trying to write a script to play a sound when ANOTHER avatar collides with a prim. But I don't want it to play when MY avatar collides with it. But, I cant figure how to do it, If anyone has an idea how to help I would be most grateful.

This is what I have so far.


string Start_Event = "sound1";
string Stop_Event = "sound2";
string Cont = "sound3";


default
{
state_entry()

{
llVolumeDetect(TRUE);//So you can walk thru it
llSay(0, "Hello, Avatar!";);//to help test
}
touch_start(integer total_number)
{
llSay(0, "Touched.";);//to help test
}

collision_start(integer num_detected) {
llPlaySound(Start_Event, 1.0);
llSleep(1.0); //for a pause
llLoopSound(Cont, 1.0); //same volume info as above

}

collision_end(integer num_detected) {
llStopSound();//to stop the loop sound when collisions over
llSleep(3.0);// a gap before the final sound
llPlaySound(Stop_Event, 0.2);
}
}


Many thanks in hope.

Regards

Katelyn
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
07-31-2006 16:49
Try this, hopefully it'll point you in the right direction...

CODE

string Start_Event = "sound1";
string Stop_Event = "sound2";
string Cont = "sound3";


default
{
state_entry()
{
llVolumeDetect(TRUE);//So you can walk thru it
}

collision_start(integer num_detected)
{
if (llDetectedKey(0) != llGetOwner())
{
llPlaySound(Start_Event, 1.0);
llSleep(1.0); //for a pause
llLoopSound(Cont, 1.0); //same volume info as above
}
}

collision_end(integer num_detected)
{
if (llDetectedKey(0) != llGetOwner())
{
llStopSound();//to stop the loop sound when collisions over
llSleep(3.0);// a gap before the final sound
llPlaySound(Stop_Event, 0.2);
}
}
}


And please use PHP tags when posting scripts. See the sticky thread at the top of this forum for instructions on how to do that.
Katelyn Brock
Registered User
Join date: 15 Jun 2006
Posts: 5
Ooops I got it wrong
07-31-2006 17:09
Many thanks Ziggy it worked fine.

But like an idiot I should have said Avatar attachment. Thats why i was having the trouble.

If you know the answer it would be wonderful.

By the way, I didn't understand the PHP, sorry, i'll do better next time.

Kindest regards

Katelyn
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-01-2006 10:30
I don't understand the problem. Is this script in something that's worn as an attachment? So you're wearing this, and you want it to play the sound if you bump into another person, but not if you're walking around in a house and bump into any object? I'm not sure what exactly you're trying to do.

For info on PHP tags, look at the second post in this thread:

/54/46/121753/1.html