Library: Low lag sensor script to trigger when avatar comes close
|
|
Mr Greggan
Registered User
Join date: 5 Mar 2007
Posts: 5
|
02-24-2008 15:34
Every 5 seconds, this script looks for an avatar within 15 meters. If detected, a command is whispered to a sign to turn on, and an invitation is said on chat channel 0. It will keep scanning for avatars within 15 meters every 5 seconds, but will not chat or turn on sign while somebody is nearby. Once the avatar leaves (greater than 15 meters away), the sign turns off, ready to turn on when the next avatar comes by. // ------------------------------------------ // Game Attraction Script // By Mr Greggan // 02-24-2008 // Public Domain.... have fun with this script! integer SomebodyNear = 0; default { state_entry() { llSetTimerEvent(5.0); } timer() { llSensor("",NULL_KEY,AGENT,15,PI); } sensor(integer num_detected) { if (SomebodyNear == 0) { llWhisper(23, "Sign_On"  ; // Turn on the sign advertising this game llSay(0, "Hello, come try this game!"  ; SomebodyNear = 1; } } no_sensor() { llWhisper(23, "Sign_Off"  ; // Turn off the sign advertising this game SomebodyNear = 0; } } // ------------------------------------------
|
|
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
|
Library bump
02-25-2008 12:07
_____________________
i've got nothing. 
|
|
Imaze Rhiano
Registered User
Join date: 27 Dec 2007
Posts: 39
|
02-25-2008 22:03
Why not to use llSensorRepeat instead of timer?
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-25-2008 22:41
perhaps to limit av detection to the current sim for edge parcels (sensor repeat will go across borders, sensor won't) or eliminate the related bug where agents on the sim edge get reported regardless of distance. or perhaps OP didn't know it was available.
_____________________
| | . "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... | - 
|
|
Mr Greggan
Registered User
Join date: 5 Mar 2007
Posts: 5
|
02-25-2008 23:32
From: Void Singer perhaps to limit av detection to the current sim for edge parcels (sensor repeat will go across borders, sensor won't) or eliminate the related bug where agents on the sim edge get reported regardless of distance. or perhaps OP didn't know it was available. Those are all good reasons to avoid the llSensorRepeat. Mainly, I didn't know too much about that function. I just wanted to keep this simple and low lag. I did figure out that this section: sensor(integer num_detected) { if (SomebodyNear == 0) { llWhisper(23, "Sign_On"  ; // Turn on the sign advertising this game llSay(0, "Hello, come try this game!"  ; SomebodyNear = 1; // THIS SHOULD BE FIRST } } Works better with this change: { SomebodyNear = 1; // LIKE THIS llWhisper(23, "Sign_On"  ; // Turn on the sign advertising this game llSay(0, "Hello, come try this game!"  ; } A minor point, but it makes for better coding I think.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
02-26-2008 08:36
you can also speed up you logical processing by changing the 'somebodyNear' boolean to 'nobodysAround'
then your if statment in the sensor event could be if (nobodysAround){ nobodysAround = !nobodysAround; //-- etc }
of course you should probably have similar logic in your no sensor, to keep it from spamming the off command if there's not any traffic for awhile (in which case it doesn't matter which logical order you use, because one teset will always be (boolean) and one will always be (!boolean)... 'boolean' should go in the place that's most likely to occur during a given time, or default to the active if it's about equal)
_____________________
| | . "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... | - 
|
|
Annabelle Babii
Unholier than thou
Join date: 2 Jun 2007
Posts: 1,797
|
03-09-2008 11:23
if you put the sensor in the sign, you can use llMessageLinked rather than llSay and llListen.
|
|
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
|
03-13-2008 18:04
If it's just a colour/alpha change to light up the sign.. why even bother with a message.. just change the settings on the linked prims~
|
|
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
|
03-13-2008 19:01
The irony is that it is labeled "Low lag sensor" but everyone knows that it WILL be used to trigger scripts that will lag the shit out of you.
|
|
Rickeh Tepper
Registered User
Join date: 15 Apr 2008
Posts: 14
|
04-21-2008 02:03
From: Ollj Oh The irony is that it is labeled "Low lag sensor" but everyone knows that it WILL be used to trigger scripts that will lag the shit out of you. rofl
|