Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Greeter with sound?

Candy Lisle
No one special just...
Join date: 26 Feb 2007
Posts: 110
01-17-2010 21:20
I have had a custom sound created that greets people. How can i have this be triggered when people come close to a prim and play this sound?
_____________________

http://slurl.com/secondlife/Oasis%20Dreams/164/224/28
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-17-2010 21:50
you want that to be every time, or just if it hasn't greeted that person recently (les spam, although since it's a sound everyone in range will be spammed with the sound anyway)

every time is fairly easy, just use llSensorRepeat, and llTriggerSound, although this will keep going till they leave the scan area.

to stop it from doing that, you'll need to store the name or key of the detected avatars, and only trigger when you find someone new.

there's an example of how that might work @
https://wiki.secondlife.com/wiki/User:Void_Singer/Programs#v7-D_Advanced_Visitor_Greeter
although you'd need to incorprate the sound by the llInstantMessage line
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Candy Lisle
No one special just...
Join date: 26 Feb 2007
Posts: 110
01-18-2010 05:05
From: Void Singer
you want that to be every time, or just if it hasn't greeted that person recently (les spam, although since it's a sound everyone in range will be spammed with the sound anyway)

every time is fairly easy, just use llSensorRepeat, and llTriggerSound, although this will keep going till they leave the scan area.

to stop it from doing that, you'll need to store the name or key of the detected avatars, and only trigger when you find someone new.

there's an example of how that might work @
https://wiki.secondlife.com/wiki/User:Void_Singer/Programs#v7-D_Advanced_Visitor_Greeter
although you'd need to incorprate the sound by the llInstantMessage line


I would like to have something that just simply plays the sound every time. I'm pretty lost with that script figuring out what to do.
_____________________

http://slurl.com/secondlife/Oasis%20Dreams/164/224/28
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-18-2010 05:37
k, here's links to the pages for the functions you need.

https://wiki.secondlife.com/wiki/LlSensorRepeat
https://wiki.secondlife.com/wiki/State_entry
https://wiki.secondlife.com/wiki/LlTriggerSound
https://wiki.secondlife.com/wiki/Sensor

place llSensorRepeat in state_entry, and llTriggerSound in sensor, all of that goes in the default state, and done.

the repeat seconds should be slightly longer than the sound takes to play (it won't trigger overlaps)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
01-18-2010 06:41
You might find it just as easy, and less continuous wear and tear on the sim, to trigger your greeter by collision instead of running a sensor all the time. Put llVolumeDetect(TRUE) in your state_entry event and then put the llPlaySound and other greeting messages in a collision_start event. Put the script in an invisible prim that people are likely to bump into, and it will do the job for you. Here's a greeter/counter I've been using recently. See it in action at http://slurl.com/secondlife/Info%20Island/125/109/34 .

CODE

list visitor_list = [];
integer count = 0;

integer isNameOnList( list list_name, string name ) // Checks to see if av has been here before
{
integer len = llGetListLength( list_name );
integer i;
for( i = 0; i < len; i++ )
{
if( llList2String(list_name, i) == name )
{
return TRUE;
}
}
return FALSE;
}

default
{
state_entry()
{
llVolumeDetect(TRUE);
}

collision_start(integer num)
{
// The next 4 lines and the if test determine which direction hit the detector from
vector lvVelocity;
float lfAngle;
lvVelocity = llDetectedVel(0);
lfAngle = llFabs(llAcos(llVecNorm(llRot2Fwd(llGetRot())) * llVecNorm(lvVelocity)));
if (lfAngle < PI_BY_TWO) // If from the -X direction ....
{
integer j;
for (j=0; j < num; j++)
{
string keyname = (string)llDetectedKey(j);
string detected_name = llGetSubString(keyname,-8,-1); //Last 8 chars of UUID (saves memory)
if (isNameOnList(visitor_list, detected_name) == FALSE)
{
visitor_list += detected_name;
++count;
llSetSoundQueueing(TRUE);
llPlaySound(llGetInventoryName(INVENTORY_SOUND,0),0.7);
llPlaySound(llGetInventoryName(INVENTORY_SOUND,1),0.7);
}
if(count >= 180) //Limit visitor list to 180 to save memory
{
visitor_list += llList2String(visitor_list,0); // Move oldest name to end of list
visitor_list = llList2List(visitor_list,1,-1); //Remove oldest name
}
}
}
}

touch_start(integer num)
{
if (llDetectedKey(0) == llGetOwner()) // Owner measure traffic count
{
llInstantMessage(llGetOwner(), "We have had " + (string)count + " unique visitors through this entrance.");
}
}
}
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at