Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Tracking beyond 10m/64m

Mist Hydraconis
Registered User
Join date: 5 May 2009
Posts: 16
06-06-2009 00:45
Ok I am trying to make a prim that when commanded will search out and go to then follow a target. So far I can make this work with llMoveToTarget but with a limit of 64m, I want to go beyond this. I have looked into llSetPos also but that only jumps 10m.

I have included the code but please ignore my ignorance since there maybe an easier way to do this. All OwnerSays are used for debugging this thing for now. Part of this code was ripped from the autotracking from OMNI since it works really well :)

integer locked = FALSE;
string target;
string ctn;
string numn;
integer master = TRUE;
integer stayput = FALSE;
vector offset = <-1,0,1.3>;

default
{
state_entry()
{
integer StealthState = FALSE;
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
llMoveToTarget(pos,0.1);
key id = llGetOwner();
llListen(9, "_BroadCast_Menu", "", "";);
llSensorRepeat("",id,AGENT,96,2*PI,.4);
}

listen(integer chan, string name, key id, string msg)
{
list info = llGetObjectDetails(id,[OBJECT_OWNER]);
if(llList2Key(info,0) == llGetOwner())
{
if(llGetSubString(msg,0,0) == "n";)
{
master = FALSE;
stayput = FALSE;
integer name = TRUE;
target = llGetSubString(msg,2,-1);
llOwnerSay(target);

llSensorRepeat("","",AGENT,96.0,TWO_PI,.45);
}
else if(llGetSubString(msg, 0, 0) == "c";)
{
master = TRUE;
stayput = FALSE;
llOwnerSay("Returning.....";);

llSensorRepeat("", llGetOwner(),AGENT,96,2*PI,.4);
}
else if(llGetSubString(msg, 0, 0) == "t";)
{
master = FALSE;
stayput = TRUE;
llOwnerSay("Staying put Master....";);
llSensorRepeat("",id,AGENT,96,2*PI,.4);
}


}



}
sensor(integer num)
{
if(master == TRUE && stayput == FALSE)
{
vector post = llDetectedPos(0);
offset =<-1,0,1.3>;
post+=offset;
llMoveToTarget(post,.3);
}
else
{
if(locked == TRUE && stayput == FALSE)
{
if(llGetPos() != (llDetectedPos(0) + offset))
{
if(llGetStatus(STATUS_PHYSICS) == TRUE)
{
llMoveToTarget(llDetectedPos(0) + offset,.23);
}
else
{
llSetPos(llDetectedPos(0) + offset);
}

}
locked =FALSE;
}
else if(locked == FALSE && stayput == FALSE)
{
integer ct = 0;
while(ct < num)
{
ctn = (string)ct;
llOwnerSay(ctn);
numn = (string)num;
llOwnerSay(numn);
llOwnerSay("Searching...";);
string found = llGetSubString(llToLower(llDetectedName(ct)),0,3);
llOwnerSay(found);
string short = llGetSubString(llToLower(target),0,3);
llOwnerSay(short);
if(short == found)
{
llOwnerSay("Attack";);
llSensorRepeat("",llDetectedKey(ct),AGENT|ACTIVE,96.0,TWO_PI,.25);

locked = TRUE;
}

ct = ct + 1;
}



}
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 03:55
warpPos and JumpPos will both work over 10m, and similar to warpPos, if you break llMoveToTarget calls into 60m calls untill you get where you're going, then that'll work too

if (llVecDist( llGetPos(), target ) > 60 )
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -