Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Radar dosn't clear last agent

Maggiedoll Alter
Registered User
Join date: 29 Feb 2008
Posts: 30
08-17-2008 13:43
I've been working on modding chav's radar script, and it seems that the last avatar detected remains listed, even after they've left range. I upped the range, and changed it to be automatically on on attach.. I'm pretty new at scripting, maybe this is just a bit too complicated for me, but I can't figure out why it still displays the last person even after they've left range, or quite how to fix it.. Been looking through all the sample scripts and tutorials, and something must just not be clicking.. sorry about the stupid question..

//Chav's Radar Script - September 2007
//Maggiedoll's working mod of chav's radar script
//range 96meters, turns on on attatch aug 2008

default
{
attach(key id)
{
llSetText("", <1,1,1>, 1);
llGetOwner();
llSensorRepeat("", NULL_KEY, AGENT, 96, PI, 1);
state running;
//clear the hover text (just in case), get owner, enter state running
//turn on on attatch
}

touch_start(integer total_number)
{
llSetText("", <1,1,1>, 1);
llGetOwner();
state running;
//clear the hover text (just in case), get owner, enter state running
//turn on if switched off
}
}

state running
{
state_entry()
{
llOwnerSay("Radar active. Scanning...";);
llSensorRepeat("", NULL_KEY, AGENT, 96, PI, 1);
//start scan and tell owner
//start scan on attatch
}

sensor(integer num_detected)
{
string results;
integer x;
for (x=0 ; x < num_detected ; x++)
{
integer distance = (integer)llVecDist(llGetPos(), llDetectedPos(x));
results += llDetectedName(x) + " (" + (string)distance + "m)\n";
}
//not entirely sure, I ripped this bit from the freebie IBM radar script so your guess is as good as mine and possibly better
llSetText(results, <1,1,1>, 1);
//display results
}


touch_start(integer total_number)
{
llOwnerSay("Switching off...";);
llSensorRemove();
llSetText("", <1,1,1>, 1);
state default;
//switch off, clear hover, and return to state default

}
}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
08-17-2008 16:11
The sensor event is not triggered after the last agent leaves, so the floating text will remain:)
What you need is a no_sensor event handler to clear the float text:
no_sensor()
{
llSetText("", <1,1,1>, 1);
}

Furthermore it would be a fantastic good idea to give the results variable an initial value:
string results="";
_____________________
From Studio Dora
Maggiedoll Alter
Registered User
Join date: 29 Feb 2008
Posts: 30
08-18-2008 18:35
From: Dora Gustafson
The sensor event is not triggered after the last agent leaves, so the floating text will remain:)
What you need is a no_sensor event handler to clear the float text:
no_sensor()
{
llSetText("", <1,1,1>, 1);
}

Furthermore it would be a fantastic good idea to give the results variable an initial value:
string results="";


Thank you! Don't know why that didn't occur to me..