I'm making a personal avatar scanner with a few open source ones I've found:
CODE
list gHere = [];
float maxDistScan = 96.0;
default
{
state_entry()
{
//define current avatar/prim position here
llSensorRepeat("", "", AGENT, maxDistScan, 2*PI, 1.0);
}
no_sensor()
{
// If nobody is detected, everyone has left
// Go through old list and say that everyone on it has gone
llSetText("no AV to scan", <0,0,0>, 1.0);
if (gHere != []) {
integer f;
integer c = llGetListLength(gHere);
for (f=0; f<c; f++) { // go through old list
llOwnerSay(llList2String(gHere, f) + " has left chat range");
}
gHere = [];
}
}
sensor(integer total_number)
{
string wholedata = (string)total_number + " AVs within 96m\n "; //display number detected
integer f = 0;
integer s = llGetAgentInfo( llDetectedKey(f) );
string status = ""; //certain agent's status
string name;
list here = [];
integer detDist;
vector myPos = llGetPos();
vector detPos = llDetectedPos(f);
detDist = (integer)llVecDist(myPos, detPos);
for(f=0; f<total_number; f++) {
name = llDetectedName(f);
here += name;
if (llListFindList(gHere, [name]) == -1) llSay(0,"Some text");
if(s & AGENT_AWAY){status += "A ";} //if agent doing any of these things, add appropriate letter to singledata
if(s & AGENT_BUSY){status += "B ";}
if(s & (AGENT_FLYING | AGENT_IN_AIR)){status += "F ";}
if(s & AGENT_MOUSELOOK){status += "M ";}
if(s & AGENT_ON_OBJECT){status += "O ";}
if(s & AGENT_SITTING){status += "S ";}
if(s & AGENT_TYPING){status += "T ";}
if(s & AGENT_WALKING){status += "W ";}
wholedata += name + " (" + (string)llRound(llVecDist(llDetectedPos(f), llGetPos())) + "m) " + status + "\n "; //creates singledata, ex: Sirius Newbold (2m) F
}
// Now check to see if anyone has left,
// based on the list from the last scan
here = llListSort(here, 1, TRUE); // sort list
integer c = llGetListLength(gHere);
if (here != gHere) { // if new list not the same as old one
for (f=0; f<c; f++) { // go through old list
name = llList2String(gHere, f);
// If anyone on old list is not on new list,
// say that they have left
if (llListFindList(here, [name]) == -1) llOwnerSay(name + " has left the chat range :))");
}
}
// Update old list variable
gHere = here;
llSetText(wholedata, <1,1,1>, 1.0); //display all data
}// end of sensor
}// end of default
The thing that it is I want it to say to the owner if someone has entered or left chat range. I adapted this:
CODE
integer detDist;
vector myPos = llGetPos();
vector detPos = llDetectedPos(f);
detDist = (integer)llVecDist(myPos, detPos);
/// then I can make this to detect a different range:
if (detDist<=19) {
llOwnerSay(" name + ("has entered the chat range");
}
else if (detDist>19){
llOwnerSay(" name + ("has entered the chat range");
}
Now the big problem and my question:
It works and detects a range shorter than the 96.0 I want to scan but the llOwnerSay keep looping and spamming the chat.
and if i use the llListFindList it will assume the 96.0 range i am using with the llSensorRepeat function.
A work around could be a new script just to scan the 19 chat range i want but then it will be more laggy and using more resources.
Any suggestion???
(PS: It might be under my nose, but sharing is golden and I'd love to learn more
))