Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How would I make this detect objects that i DONT own?

Naomi Babcock
Registered User
Join date: 25 May 2006
Posts: 5
12-24-2006 14:24
string text;
vector pos;
integer many;
key sub;
integer info;
key owner;
list extra;

default {
on_rez(integer param) {
llResetScript();
}

state_entry() {
owner = llGetOwner();
llSetText("SCRIPTED RADAR SWEEP SEARCHING...", <1,0,0>, 1);
llSetTimerEvent(.5);
}

timer() {
llSensor("", NULL_KEY, ACTIVE | SCRIPTED, 300, PI);
}

no_sensor() {
llSetText("No scripted objects within 96m", <0,1,0>, 1);
}

sensor(integer num) {
text = "FULL RADAR SWEEP\n";
many = 1;
pos = llGetPos();
integer x=0;
for(x;x<num;x++) {
extra = [];
sub = llDetectedKey(x);
if(sub != owner) {
info = llGetAgentInfo(sub);
if(info & AGENT_TYPING) extra += ["Ty"];
if(info & AGENT_AWAY) extra += ["AFK"];
if(info & AGENT_BUSY) extra += ["BUSY"];
if(info & AGENT_FLYING) extra += ["Fly"];
if(info & AGENT_MOUSELOOK) extra += ["Mous"];
if(info & AGENT_ON_OBJECT) {
extra += ["Sat"];
} else if(info & AGENT_SITTING) {
//extra += ["S-G"];
}
if(info & AGENT_SCRIPTED) {
//extra += ["S-att"];
} else if(info & AGENT_ATTACHMENTS) {
//extra += ["At"];
}
if(info & AGENT_WALKING) extra += ["Wa"];
if(info & AGENT_CROUCHING) extra += ["Cr"];
if(info & AGENT_ALWAYS_RUN) extra += ["Run"];
if(info & AGENT_IN_AIR) extra += ["Air"];

text += (string)many + ";) " + llDetectedName(x) + "-" + (string)(llRound(llVecDist(pos, llDetectedPos(x)))) + "m\n";

many++;
}
}

if(many == 1) text = "No scripts within 96m";
llSetText(text, <0,0,1>, 1);
}
}
Naomi Babcock
Registered User
Join date: 25 May 2006
Posts: 5
12-24-2006 15:12
anyone? ^^
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-24-2006 15:46
Explicitly you cant, you can only detected everything and then filter out stuff owned by you.
But you have a fixed 16 item return so it would be pretty bad.
Peekay Semyorka
Registered User
Join date: 18 Nov 2006
Posts: 337
12-24-2006 15:53
Unfortunately sensors can only detect 16 objects at a time, and there is no way to pre-filter only the ones you don't own. So your own objects might mask those you do not own.

Eg., if you own 15 nearby objects, the sensor might only detect one not-owned object before hitting the 16-object limit.

With such limitation in mind you can try the script below. Put it in a prim and touch it.

-peekay

CODE

// Script to detect unowned objects.
// Put this script into a prim then touch it.
//
// Peekay Semyorka: free for redistribution.

// Maximum detection distance possible is 96 meters
integer MAX_DISTANCE = 96;

key ownerKey = NULL_KEY;

default
{
on_rez(integer start)
{
llResetScript();
}

state_entry()
{
ownerKey = llGetOwner();
}

touch_start(integer total_number)
{
integer i;
for (i = 0; i < total_number; i++)
{
if (llDetectedKey(i) == ownerKey)
{
llSensor("", NULL_KEY, ACTIVE | PASSIVE | SCRIPTED, MAX_DISTANCE, PI);
}
}
}

no_sensor()
{
llOwnerSay("No unowned objects detected within " + (string) MAX_DISTANCE + "m");
}

sensor(integer total_number)
{
string objectName;
vector objectPos;
vector pos = llGetPos();

integer i = 0;
for (i = 0; i < total_number; i++)
{
if (llDetectedOwner(i) != ownerKey)
{
llOwnerSay("Not-owned object [" + llDetectedName(i) + "] at "
+ (string) llDetectedPos(i) + " ("
+ (string) llRound(llVecDist(pos, llDetectedPos(i)))
+ "m away)");
}
}
}

}