Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

simple scanner bug

Haru Radek
C:SI komodo samurai clan
Join date: 16 Nov 2007
Posts: 3
03-28-2008 20:23
Hello, i've this simple scanner script with a bug inside:)...its attached on me and if i type "/1list" give me the list of agents near me (range 96mt), and this is exactly what i want from this script..xD

but sometimes, when i change sim or simply relog, keep in memory the last scanning data..
i call "bug" this issue but i'm sure that is a programming fault...:D
CODE

string data ;
key lastOwner;

default {

attach(key id) {
llOwnerSay("type /1 list on chat to start the scanning");
if(lastOwner!=llGetOwner()) {
llResetScript();
}
}

state_entry() {
lastOwner=llGetOwner();
llSetAlpha(0.0, ALL_SIDES);
llSensorRepeat("", NULL_KEY, AGENT, 96.0, 2*PI, 0.1);
llListen(1,"",llGetOwner(),"");
}

sensor(integer num_detected) {
data = "--" + (string)num_detected + " agents detected 96mt--\n ";

integer p = 0;
for(p = 0; p< num_detected; ++p) {
string status = "";
integer s = llGetAgentInfo( llDetectedKey(p) );

if(s & AGENT_AWAY){status += "A ";}
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 ";}
data += llDetectedName(p) + " (" + (string)llRound(llVecDist(llDetectedPos(p), llGetPos())) + "m) " + status + "\n ";
}
}

listen(integer a, string b, key c, string msg) {
if(msg == "list") {
llOwnerSay(data);
}
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
03-29-2008 03:11
I'm not really clear what you're saying the problem is but...

The 'data' gets refreshed with every scan, which is set VERY aggressively. At 0.1 seconds per scan I doubt the code even has time to compile its list before it has queued several further scans.

I would try triggering the scan from the command:

default
{
state_entry()
{
llSetAlpha(0.0, ALL_SIDES);
llListen(1,"",llGetOwner(),"";);
}

attach(key id)
{
llOwnerSay("type /1 list on chat to start the scanning";);
}

listen(integer a, string b, key c, string msg)
{
if(msg == "list";) llSensor("", NULL_KEY, AGENT, 96, TWO_PI);
}

sensor(integer num_detected)
{
llOwnerSay("--" + (string)num_detected + " agents detected 96mt--";);

integer p = 0;
for(p = 0; p< num_detected; ++p)
{
string status = "";
integer s = llGetAgentInfo( llDetectedKey(p) );

if(s & AGENT_AWAY){status += "A ";}
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 ";}
llOwnerSay(llDetectedName(p) + " (" + (string)llRound(llVecDist(llDetectedPos(p), llGetPos())) + "m) " + status);
}
}

changed(integer change)
{
if(change & CHANGED_OWNER) llResetScript();
}
}

...and the Lag Monster won't thank you, but everyone else will! :D
Haru Radek
C:SI komodo samurai clan
Join date: 16 Nov 2007
Posts: 3
03-29-2008 03:41
thx Pale!!...now work perfectly..xD
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
03-29-2008 04:24
the code is object orientated.
the timer floods the query and the datas-variables get out of sync with the variable-data processing.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
03-29-2008 05:42
In practice, fast timers and sensors actually don't really get out of sync.
_____________________