Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Avatar Alert Script question...

Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-20-2006 19:22
Hello,

I am using an open source Avatar Alert script. Ther eare a few issues I am having with it though and I can't seem to locate the errors...

1. When the llSetText is set only the last avatar detected is displayed. I think all the detected avatars should be listed?

2. The "No Sensor" section at the bottom does not seem to work. I think it is detecrting me so it always is detecting someone?

3. Would be really nice to choose to turn the "display" on and off. Always have the report sent via llOwnerSay and toggle the llSetText display.

Thanks in advance for all the help.

CODE

integer switch=0;
key name;


default
{
state_entry()
{
llListen(77,"", NULL_KEY,"");
}

on_rez(integer num)
{
llResetScript();
}
listen(integer channel, string name, key id, string message)
{
if (message == "on")
{
switch=1;
llSensorRepeat("","",AGENT,96.0,PI,60.0);
llOwnerSay("Alert on");
}
else if (message == "off")
{
switch=0;
llSensorRemove();
llOwnerSay("Alert off");
}
}

sensor(integer total_number)
{
vector pos = llGetPos();
integer j;
integer count = total_number;
for (j = 0; j < count; j++)
{
if(llDetectedKey(j) != name)
{
float diff = llVecDist(pos,llDetectedPos(j));
integer dist = llRound(diff);
string result = (llDetectedName(j)) + " " + ((string)dist) + "m";
llOwnerSay(result);
llSetText(result,<1,1,1>,1);
}
}
}

no_sensor()
{
llOwnerSay("Nothing Found");
llSetText("",<0,0,0>,0);
}

}
Evan Oud
Registered User
Join date: 18 Apr 2005
Posts: 30
I belive this is what you are wanting
02-20-2006 22:30
I belive this is what you are looking for, what you need to do is put all the detected avatars in a list then show the result.

CODE

//////code starts here

key name;
default



{
state_entry()
{
llSensorRepeat("", NULL_KEY, AGENT, 512.0, TWO_PI, 1);
name = llGetOwner();
}

sensor(integer num)
{


vector pos = llGetPos();






string text = "";
integer j;

// float diff = llVecDist(pos,llDetectedPos(j));
//integer dist = llRound(diff);




for (j = 0; j < num; j++)
{

float diff = llVecDist(pos,llDetectedPos(j));
integer dist = llRound(diff);
text += llDetectedName(j) + " " + ((string)dist) + "m" + "\n";
}
llSetText(text, <1,1,2>, 1);
}


no_sensor()
{
llSetText("Nobody", <0,1,1>, 1);
}
}
Ares Desmoulins
Registered User
Join date: 13 Sep 2005
Posts: 22
02-20-2006 22:53
Basically, what is happening is in your sensor function; you are overwriting the last avatar detected =) every time llsettext is called with the new data, the previous one is replaced with the new one. The switch you started to implement is definately the right idea; Use the example below using if statements to utilize it. As for your no_sensor function, you don't happen to be within 96m of your scanner at the time, do you? the sensor will detect you, too, causing the no_sensor function to never fire =)

Try The Following; it has a touch function to turn off the display as you were looking for as well, using the switch integer as a toggle:

CODE

integer switch;
integer display;

default
{
state_entry()
{
llListen(77,"", NULL_KEY,"");
}

on_rez(integer num)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
if (message == "on")
{
switch = 1;
display = 1;
llSensorRepeat("","",AGENT,96.0,PI,60.0);
llOwnerSay("Alert on");
}
else if (message == "off")
{
switch = 0;
display = 0;
llSensorRemove();
llSetText("",<1,1,1>,0);
llOwnerSay("Alert off");
}
}

touch(integer touched)
{
if(switch == 1)
{
if(display == 1)
{
display = 0;
llSetText("",<1,1,1>,0);
llOwnerSay("Display Off");
}
else
{
display = 1;
llOwnerSay("Display On");
}
}
}

sensor(integer sensed)
{
string result = "";
vector pos = llGetPos();
integer j;
for (j = 0; j < sensed; j++)
{
integer dist = llRound(llVecDist(pos,llDetectedPos(j)));
result += (llDetectedName(j)) + " " + ((string)dist) + "m" + "\n ";
}
if(display == 1)
{
llSetText(result,<1,1,1>,1);
llOwnerSay(result);
}
else
{
llSetText("",<1,1,1>,0);
llOwnerSay(result);
}
}

no_sensor()
{
llOwnerSay("Nothing Found");
llSetText("",<0,0,0>,0);
}
}
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-20-2006 23:45
Hi Ares, Thank you Thank you!

This is working as I had hoped. the dispaly touch toggle is a bit funky in that it seems to cycle through the off on off real fast in a row ?

Object: Display Off
Object: Display On
Object: Display Off

The other part I noticed is that the orginal script formatted the chat text differently. before I had this...

Object: Sydney Alexander @ 4m
Object: Jocelyn McLuhan @ 9m <---Each avatar is on it's own line

Object: Jocelyn McLuhan @ 3m
Sydney Alexander @ 13m <--- One long message, a run-on

not a big deal at all and I can mess with the formmatting, but if the old otput is possible?

the last thing to ad is the ability to set the scan range and frequency by voice. I know how to make them global at the top, but parsing the right part from the chat... YOu have given me much to work with.

Thank you again.


From: Ares Desmoulins
Basically, what is happening is in your sensor function; you are overwriting the last avatar detected =) every time llsettext is called with the new data, the previous one is replaced with the new one. The switch you started to implement is definately the right idea; Use the example below using if statements to utilize it. As for your no_sensor function, you don't happen to be within 96m of your scanner at the time, do you? the sensor will detect you, too, causing the no_sensor function to never fire =)

Try The Following; it has a touch function to turn off the display as you were looking for as well, using the switch integer as a toggle:

CODE

integer switch;
integer display;

default
{
state_entry()
{
llListen(77,"", NULL_KEY,"");
}

on_rez(integer num)
{
llResetScript();
}

listen(integer channel, string name, key id, string message)
{
if (message == "on")
{
switch = 1;
display = 1;
llSensorRepeat("","",AGENT,96.0,PI,60.0);
llOwnerSay("Alert on");
}
else if (message == "off")
{
switch = 0;
display = 0;
llSensorRemove();
llSetText("",<1,1,1>,0);
llOwnerSay("Alert off");
}
}

touch(integer touched)
{
if(switch == 1)
{
if(display == 1)
{
display = 0;
llSetText("",<1,1,1>,0);
llOwnerSay("Display Off");
}
else
{
display = 1;
llOwnerSay("Display On");
}
}
}

sensor(integer sensed)
{
string result = "";
vector pos = llGetPos();
integer j;
for (j = 0; j < sensed; j++)
{
integer dist = llRound(llVecDist(pos,llDetectedPos(j)));
result += (llDetectedName(j)) + " " + ((string)dist) + "m" + "\n ";
}
if(display == 1)
{
llSetText(result,<1,1,1>,1);
llOwnerSay(result);
}
else
{
llSetText("",<1,1,1>,0);
llOwnerSay(result);
}
}

no_sensor()
{
llOwnerSay("Nothing Found");
llSetText("",<0,0,0>,0);
}
}
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-21-2006 07:14
You can pick up an open-source monitor like this for L$1 at Skyhook Station, 500m above Avalon Lagoon in LostFurest dAlliez. It's BSD-licensed, free to hack on, AND has a cute otter icon (based on my forum avatar) in the HUD.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
02-21-2006 07:45
I've got three different avatar alert scripts at my home area in Theretra, which you might be interested to look at. They're all L$1 and full mod/copy, just not for resale on their own.

The first one is a chat notifier HUD which tells you when people enter and leave a 20m radius, and also has a list of who is within that radius. It's pretty simple to change 20 to 96 in the script. That's probably closest. (I use this all the time myself, I find it invaluable.)

The second is a text radar display that tells you who's within 96m and how fast they are moving towards or away from the radar.

The third is an early warning security device, the Defensive Panopticon, that scans for avatars on a ban list that you put on a notecard, sets off an alarm and displays their name if they come within range, and (if you tell it to) ejects them automatically if they're on your land. I don't like "security" scripts in general but this one has to have names specified for it, so there's no danger of knocking out passers-by accidentally.

None of them have cute otter icons, though. The Panopticon is downright sinister.
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-21-2006 07:56
Well I will have to check these out. I saw the Defensive Panopticon device and you are right... "The Panopticon is downright sinister"

I too am not a huge fan of security nor do I really need it, but if I did I woudl think your solution is the easiest and most "friendly". I may have to give it a try...

Thanks

From: Ordinal Malaprop
I've got three different avatar alert scripts at my home area in Theretra, which you might be interested to look at. They're all L$1 and full mod/copy, just not for resale on their own.

The first one is a chat notifier HUD which tells you when people enter and leave a 20m radius, and also has a list of who is within that radius. It's pretty simple to change 20 to 96 in the script. That's probably closest. (I use this all the time myself, I find it invaluable.)

The second is a text radar display that tells you who's within 96m and how fast they are moving towards or away from the radar.

The third is an early warning security device, the Defensive Panopticon, that scans for avatars on a ban list that you put on a notecard, sets off an alarm and displays their name if they come within range, and (if you tell it to) ejects them automatically if they're on your land. I don't like "security" scripts in general but this one has to have names specified for it, so there's no danger of knocking out passers-by accidentally.

None of them have cute otter icons, though. The Panopticon is downright sinister.
Sydney Alexander
Registered User
Join date: 19 Feb 2005
Posts: 69
02-21-2006 07:57
Thank you Argent. I will certainly take a look! :)

From: Argent Stonecutter
You can pick up an open-source monitor like this for L$1 at Skyhook Station, 500m above Avalon Lagoon in LostFurest dAlliez. It's BSD-licensed, free to hack on, AND has a cute otter icon (based on my forum avatar) in the HUD.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-21-2006 09:31
From: Ordinal Malaprop
The first one is a chat notifier HUD which tells you when people enter and leave a 20m radius, and also has a list of who is within that radius. It's pretty simple to change 20 to 96 in the script. That's probably closest. (I use this all the time myself, I find it invaluable.)
That's basically what mine does, with a touch event that cycles it through off, count, names, and names of all avs in sensor range (asleep, awake, alert, and chatty).

As it's BSD licensed you're welcome to give it away, sell it by itself or as part of another product, paint it blue and post it for ridicule in the Welcome Area, or bury it in used peat for three months and recycle it for firelighters.
From: someone
The Panopticon is downright sinister.
Is it frumious?
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
02-21-2006 09:35
It's not terribly frumious, but it does gyre and gimble.

Ooh, that av state information thing is a great idea - I think I'll put that in mine, as well. Discussion groups can be very confusing.
Tommi Vantelli
Registered User
Join date: 10 Oct 2007
Posts: 3
10-13-2007 17:45
I have a question regarding the avatar alert script I run in our house. Well, this thread is pretty old and I wonder, if I will get any response at all, but after working my way through all the threads matching my search terms, this is the closest thing and before starting a new thread, I thought it might be a good idea to give this one a try.

As I mentioned before, I run a pretty simple avatar alert script in the house where I live with my girl (my RL girl friend) and after her having some kinda nightmarish encounters with people showing up in our house while she is stripped naked for changing, we thought it would be cool to install an alert device. So far so good. The script is working fine, but now we are pretty annoyed by the frequent alert messages regarding my girl. We would like to have her also not being recognized by the alert script, and not only me as the owner of the script.

Can anybody help me out and tell me how to modify the script to meet our needs? I have no clue how to script, so go easy on me. This is the script as is:

integer switch=0;
key name;

default
{
state_entry()
{
llWhisper(0,"Alert Script Active";);
name = llGetOwner();
}

touch_start(integer total_number)
{
if(switch==0)
{
switch=1;
llSensorRepeat("","",AGENT,90.0,PI,20.0);
llWhisper(0,"Alert on";);
}
else if(switch==1)
{
switch=0;
llSensorRemove();
llWhisper(0,"Alert off";);
}
}

sensor(integer total_number)
{
vector pos = llGetPos();
integer j;
integer count = total_number;
for (j = 0; j < count; j++)
{
if(llDetectedKey(j) != name)
{
float diff = llVecDist(pos,llDetectedPos(j));
integer dist = llRound(diff);
string result = (llDetectedName(j)) + " " + ((string)dist) + "m";
llWhisper(0,result);
}
}
}

no_sensor()
{
llWhisper(0,"Nothing Found";);
}

}


Help would be highly appreciated. Kindest regards!!


Tommy V.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-13-2007 23:58
get your GF's key, add a variable at the top "key ignore = <insert GF's key here>" and the line that says
if (lldetectedkey(j) != name)

change it to
if(llDetectedKey( j ) != name && llDetectedKey( j ) != ignore)


it might also help to add a variable BEFORE that line
key vKeyDetected = llDetectedKey( j );

and replace the other places that use llDetectedKey( j ); with vKeyDetected....saves a little processing anyways

to get GF's key, make box, goto contents, press "new script"open the script from contents, add this line
llSay( 0, (string)llDetectedKey );
after the line that says touch
save, then have her touch it

EDIT: yes this could be done better. I'm tired
Tommi Vantelli
Registered User
Join date: 10 Oct 2007
Posts: 3
10-14-2007 03:34
Thank you so much for your answer, Void. But as I said earlier, I am not too familiar with scripting at all. I couldn't even get that box to work to detect the GF key, as I always got a syntax error at trying to save. I really don't know exactly where to put the line you gave me. Obviously I always did it wrong, and I tried a couple of different ways to put it in. I bet it is a problem with brackets or stuff, but I just don't know where to put them.

As I already got stuck here, I am pretty sure I would be facing similar problems changing the script itself. Sorry, I really don't want to delegate all the work as I am eager to get into scripting a little more, but at this point I am pretty helpless. A complete layout of both the scripts with the necessary alterations would be highly appreciated. But I will keep trying until I hear from anyone. Thx and regards


Tommi
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-14-2007 07:02
Have her touch this and then copy it from chat history to the gf_key entry, between the quotation marks, on the top of the second script.

CODE

default
{
touch_start(integer total_number)
{
llSay(0, (string)llDetectedKey(0));
}
}

CODE

integer switch=0;
key owner;
key gf_key = "";
default
{
state_entry()
{
llWhisper(0,"Alert Script Active");
owner = llGetOwner();
}

touch_start(integer total_number)
{
if(switch==0)
{
switch=1;
llSensorRepeat("","",AGENT,90.0,PI,5.0);
llWhisper(0,"Alert on");
}
else if(switch==1)
{
switch=0;
llSensorRemove();
llWhisper(0,"Alert off");
}
}

sensor(integer total_number)
{
vector pos = llGetPos();
integer j;
integer count = total_number;
key detected_key = llDetectedKey(j);
for (j = 0; j < count; j++)
{
if(detected_key != name && detected_key != gf_key)
{
float diff = llVecDist(pos,llDetectedPos(j));
integer dist = llRound(diff);
string result = (llDetectedName(j)) + " " + ((string)dist) + "m";
llWhisper(0,result);
}
}
}
}

Note that it is setup with a scan range of 90 meters which may be too far depending on your property, just look in the wiki to see which of the llSensorRepeat variables to change if you need to lower that. Personally this would bug me getting this spam at home if someone came along. There are many places you can go to get a free or $L1 radar hud script that will always show you who is in the area around you, no matter where you are at. I know Ordinal had a nice one at his shop.
_____________________
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
Tommi Vantelli
Registered User
Join date: 10 Oct 2007
Posts: 3
10-14-2007 07:38
First off...THX a million, Jesse!! Everything worked fine. But you are right about the spam. We will look out for a less offensive alternative. Until then, folks passing by will have to endure getting spammed. ^^ Well, we live in a pretty quite and remote part of the world. It will not annoy too much people until we get rid of it. Thx again and cheers!!


Tommi V.