|
Led Writer
Registered User
Join date: 12 Apr 2007
Posts: 14
|
10-12-2007 12:35
I've been trying to script a sensor, that says "Hello", whenever an avatar gets in range. As soon as the avatar gets outta range it should say "Goodbye". I did some research and came up with something like this: // begin code float range = 30.0; // in meters float rate = 1.0; // in seconds default { on_rez( integer param ) { llSensorRepeat( "", "", AGENT, range, TWO_PI, rate ); } state_entry() { llSensorRepeat( "", "", AGENT, range, TWO_PI, rate ); } sensor( integer detected_number ) { { integer i; if( llDetectedKey( i ) ) { llSay(0,"Hello"  ; } } } } // end code Now, whenever an avatar gets in range, the script says "Hello". The first problem is, that it keeps repeating it all the time. The second problem is, that I didnt find a solution for the "avatar gets outta range" case. I guess its kinda simple, but so far I couldn't figure it out. Thanks.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
10-12-2007 16:51
I have a script that does something like this, if I recall it basically works as follows
create a list for 'notified' avatars. Then have your sensor 1. check if they are in 'notified' list 2. if not, add them and say hello. 3. save the entire list of detected names 'latest scan'
You could then have a timer running every few seconds and comparing the most recent sensor scan to the in range list. 1. for each avatar in 'notified' list 2. check if they are in 'latest scan' 3. if not, remove them from 'notified' list, and say 'goodbye'
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-12-2007 19:59
Might want to skip the "Goodbye" part. They will be out of normal say range before they are out of sensor range and shout or an IM might be percieved as too intrusive for some. Hey, still a nice scripting excersize thou. Let us know how it comes out. You can see how to populate the list and also limit the greeting to only one time if you wanted, per patron/visitor in this thread: /54/de/215440/1.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|