Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

follow drone that stays on my parcel?

Mirabelle Silverstar
Registered User
Join date: 30 Apr 2008
Posts: 3
06-25-2008 15:44
Hi! I'd like to make an object that follows a person on my land but doesn't cross into my neighbor's parcel. I tried subdividing the land into a central area and an outer area without object entry, but I'm not allowed. I thought maybe I could combine this follow script (from the good old "wild slime";):...

default
{
state_entry()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_Z, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
llMoveToTarget(pos,0.1);
key id = llGetOwner();
llSensorRepeat("","",AGENT,200000,7000*PI,.4);
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);
vector offset =<-1,0,1>;
pos+=offset;
llMoveToTarget(pos,.3);
}
}

...with this (the only script I could find with llOverMyLand):

default {
touch_start(integer num_detected) {
// check if the touching person is over the script owner's land
if (llOverMyLand(llDetectedKey(0))) {
llSay(0, llDetectedName(0) + " is on my land.";);
} else {
llSay(0, llDetectedName(0) + " is NOT on my land.";);
}
}
}

...but I'm a total scripting noob -- can anybody help?
Thanks!
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
06-25-2008 17:21
CODE
sensor(integer n)
{
integer i = 0; //index of avs
searching = TRUE; // are we lookin'?
do
if ( llOverMyLand(llDetectedKey(i)) )
{
searching = FALSE;
} else {
i++;
}
while(searching && i <= n);

if ( i < n )
{
llMoveToTarget(llDetectedPos() + (<-1, -1, 1> * llDetectedRot(i), 0.35);
} else {
llMoveToTarget(llGetPos(), 0.35);
}
}

no_sensor()
{
llMoveToTarget(llGetPos(), 0.35);
}


Typed while tired, groggy from meds and not tested in-world, but it should get you started.
Mirabelle Silverstar
Registered User
Join date: 30 Apr 2008
Posts: 3
06-25-2008 19:05
wow, thank you! I'll go try it now. Hope you feel better soon!
Mirabelle Silverstar
Registered User
Join date: 30 Apr 2008
Posts: 3
06-26-2008 08:22
Hmm, does this work only on mainland parcels? it doesn't seem to work for me.
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
06-26-2008 10:42
llOverMyLand() doesn't work on group deeded land unless the object is deeded too. Since you can't edit any more a deeded object, that's a very bad idea.

To keep an object in a parcel, I just use the parcel name.

string StartingParcel;

kbParcelNameAt(vector there)
{
return llList2String(llGetParcelDetails(there, [PARCEL_DETAILS_NAME]), 0);
}

In you default state_entry(), you add:

StartingParcel = kbParcelNameAt(llGetPos());

And the sensor event becomes:

CODE
sensor(integer n)
{
integer i = 0;
while(i < n)
{
vector there = llDetectedPos(i) + (<-1, -1, 1> * llDetectedRot(i);
if (kbParcelNameAt(there) != StartingParcel)
{
llMoveToTarget(llGetPos(), 0.35); // Stay put.
++i;
}
else
{
i = n; // So we go only to the closest possible target.
// If you remove that line, we go to every detected AV over your land.
llMoveToTarget(there, 0.35);
}
}
}

no_sensor()
{
llMoveToTarget(llGetPos(), 0.35);
}


If you want the object to follow only you --That's what I guess from your snippet.-- the sensor event can be simplified.

First, just use:

llSensorRepeat("", llGetOwner(), AGENT, 100, PI, 0.5);

There's no need to try to sense any farther and PI already describe a full circle sensor. Then, since you're only one of a kind, no need to worry about anything but the first sensed AV.

CODE
sensor(integer n)
{
vector there = llDetectedPos(0) + (<-1, -1, 1> * llDetectedRot(0);
if (kbParcelNameAt(there) != StartingParcel)
{
llMoveToTarget(llGetPos(), 0.35); // Stay put.
}
else
{
llMoveToTarget(there, 0.35); // Or move.
}
}

Not tested in world... but I'm not under medication. ;-)