|
Sirius Newbold
Registered User
Join date: 13 Aug 2006
Posts: 3
|
05-10-2007 16:08
Hello, I'm writing an avatar scanner script and everything was going fine until I also had the script display an avatar's status with llGetAgentInfo. The script now displays an empty string, (00000-0000-00000).
I declared integer p = 0; then used for(; p<num_detected; ++p) to cycle through each person detected by the sensor event. The declaration is outside the for loop. Inside the for loop, I have s += llGetAgentInfo(llDetectedKey(p)); // s is an empty string variable declared outside the loop, and I also have these if(s & AGENT_AWAY){status += "A ";} to add an abbreviation of an avatar status to a longer string of information about the avatar. status is also an empty string var declared outside loop.
Am I making a mistake anywhere or do you need more information? Should I just post the whole script?
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
05-10-2007 21:52
From: Sirius Newbold Should I just post the whole script? yes
|
|
Sirius Newbold
Registered User
Join date: 13 Aug 2006
Posts: 3
|
05-12-2007 12:58
default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 96.0, 2*PI, 0.1); }
sensor(integer num_detected) { string status = ""; //certain agent's status string singledata = ""; //all info for single person string wholedata = ""; //all info for all people integer p = 0; //all people detected are numbered, starting with first person's number integer s = 0; //number related to status wholedata += (string)num_detected + " AVs within 96m\n "; //display number detected for(; p<num_detected; ++p) //go through each person detected and gather their data s += llGetAgentInfo(llDetectedKey(p)); 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 ";} singledata += llDetectedName(p) + " (" + (string)llRound(llVecDist(llDetectedPos(p), llGetPos())) + "m) " + status + "\n "; //creates singledata, ex: Sirius Newbold (2m) F wholedata += singledata; //add one person's data to other people's data llSetText(wholedata, <1,1,1>, 1.0); //display all data } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
05-12-2007 13:25
Your for loop is only processing the first line, you have left out the braces. Unrelated to your original question but do you really mean to combine (s += ...) every detected avatar's status information? This will give false data based on the previously detected avatars. default { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 96.0, 2*PI, 0.1); }
sensor(integer num_detected) { string wholedata = (string)num_detected + " AVs within 96m\n "; //display number detected integer p = 0; //all people detected are numbered, starting with first person's number for(p = 0; p< num_detected; ++p) //go through each person detected and gather their data { string status = ""; //certain agent's status integer s = llGetAgentInfo( llDetectedKey(p) ); 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 += llDetectedName(p) + " (" + (string)llRound(llVecDist(llDetectedPos(p), llGetPos())) + "m) " + status + "\n "; //creates singledata, ex: Sirius Newbold (2m) F } llSetText(wholedata, <1,1,1>, 1.0); //display all data } }
_____________________
I'm back......
|
|
Sirius Newbold
Registered User
Join date: 13 Aug 2006
Posts: 3
|
One more thing!
05-12-2007 14:38
yes, you're right, I meant s =. Thanks very much for your help! Works perfectly now!
Oops, actually, one more thing. Sometimes it senses avatars 500m away for a split second. How is this even possible if I set the sensor to 96m? How do I get rid of this?
|
|
Anthony Hocken
Registered User
Join date: 16 Apr 2006
Posts: 121
|
05-12-2007 19:09
Yes it'll sometimes detect avatars further away. This is just a SL querk and nothing to do with your script. Filter them out using the result from llVecDist() if you want to exclude them.
|