Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sensor funtion not working

Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
03-16-2006 10:14
I have a copy of a freebee AV sensor script that was working before the update. but now seems to be dead. Would someone tell me what might be wrong. Mod

=========================================================
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";);
}

}
==========================================================
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-16-2006 10:18
Well, I'm not quite sure what it's not doing that it did, but I'm guessing that the name variable isn't being reset. Try resetting the script, and you probably also want to add

CODE
on_rez(integer p)
{
llResetScript();
}


as well.
Kalleb Underthorn
Registered User
Join date: 30 Jul 2003
Posts: 40
03-16-2006 10:18
llSensorRepeat("","",AGENT,90.0,PI,20.0);

should be

llSensorRepeat("",NULL_KEY,AGENT,90.0,PI,20.0);


"" is not the same thing as NULL_KEY (which is a 36 character key with all zeros and dashes), the sensor treat that as a non-wildcard, and will look for something that cannot possibly exist.
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Fixed!
03-16-2006 10:35
Thanks Ordinal and Kallep. I used both suggestions and it is working again. Still don't undersand why it stopped and would not work after several resets, but what the heck. Now I can finish incorporating the basic idea into another script I was working on.

Mod

PS. Would someone tell me how to post formated scripts to the forums? I am a slow learner. lol.
Kalleb Underthorn
Registered User
Join date: 30 Jul 2003
Posts: 40
03-16-2006 10:41
In guided mode, there is a little icon that looks like a piece of paper with "php" written in it. Use that. Or you can type [ PHP ] code [ /PHP ] (sans the formatting spaces of course)