Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llMoveToTarget moving to a target far away..

Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
10-24-2007 18:58
So i wrote this nice recall locations script, but i want to make so when you teleport back to your location you were at before it allows you to move to the target, because there seems to be a bug where even though it says it's teleporting to the correct area, once it teleports to the region and point it says, it appears in some random point in the region, and you have to fly to the beacon to get to the target. How would I set up a loop which on CHANGED_REGION would move to the specified target in the region?

From: someone

move(vector targ)
{
if (llVecDist(llGetPos(), targ) < 55.0)
{
llMoveToTarget(targ, 1.0);
}
else
{
float targfar = llVecDist(llGetPos(),targ);
llMoveToTarget(llGetPos() + <targfar/3,targfar/3,targfar/3>, 0.2);// I'm very confused what to do here.. I want to make it so that it loops moving to the target, even if it's farther than 55 m away.. but i don't know what to do.
}
}
vector target;
string MySim;
vector MyPos;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
llListen(2,"",llGetOwner(),"";);
llSetTimerEvent(1);
llSleep(2);
llSetTimerEvent(600);
}
timer()
{
MyPos = llGetPos();
MySim = llGetRegionName();
llOwnerSay("Saved to Position: "+(string)MyPos+" and Region: "+MySim+".";);
}
listen(integer c, string n, key id, string msg)
{
if (msg == "recall reset"||msg == "reset";)
{
llResetScript();
}
if (msg == "recall save";)
{
llSetTimerEvent(0);
llOwnerSay("Saving last location...";);
llOwnerSay("Saved: Position "+(string)MyPos+" Region: "+MySim+".";);
llOwnerSay("No longer updating until you say /2 recall reset or /2 reset";);
}
if (msg == "recall";)
{
llOwnerSay("Opening up last location on map.";);
llMapDestination(MySim,MyPos,ZERO_VECTOR);
llOwnerSay("Click teleport to get started with your recall.";);
state movement;

}
}
}
state movement
{
changed(integer change)
{
if (change & CHANGED_REGION&llGetRegionName() == MySim)
{
target = MyPos;
llTarget(target, 0.5);
move(target);
}
}
not_at_target()
{

move(target);
}

at_target(integer tnum, vector tpos, vector opos)
{
llTargetRemove(tnum);
llMoveToTarget(llGetPos(), 0.2);
llOwnerSay("Position restored.";);
llStopMoveToTarget();
llResetScript();
state default;
}

}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-24-2007 19:21
gonna have to log for a bit and haven't looked deeply at the code but this jumped out at me:

if (change & CHANGED_REGION & llGetRegionName() == MySim)


should just be checking change against the Constants. Probably going to have to put the mysim test in an if test inside the if(change & CHANGED _REGION) test.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum