Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llMoveToTarget Broken

Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
04-16-2008 15:32
Here is a sample elevator script by Hank Ramos.

Used to work, using llMoveToTarget. Worked prior to April 8th / 9th (1 week after Havok 4.)

Now, doesn't work. Will get almost to a floor, slow right down, struggle to reach it, fall down a bit, struggle back up a bit, fall down a bit, etc. Like it hasn't quite got enough steam to do it anymore.

Testing it in a one-prim platform 3.500 x 3.500 x .5, with a mass of 61.250000 Lindens.


//to get it working, you say in open chat something like
//goto floor 5 OR goto floor 3 OR goto floor 0


vector alignment;
vector targetVector;
integer travelDistance;
integer numListen;
integer targetFloor;
list floorHeights = [19,36,46,56,66,76,86,96,106,116,126,136];
float fixedFloorHeight = 10; //Set to floor heights, or set to -1 to use floorHeights list
float speed = 0.25; //Valid values are 0.01 to 1.0, a Percentage of maxSpeed;
float maxSpeed = 32;
float precision = 0.5;
integer autoSpeed = TRUE;
integer initialDistance;

elevate (vector end)
{
vector current = llGetPos();
travelDistance = llRound(current.z-end.z);
travelDistance = llAbs(travelDistance);

if (autoSpeed)
{
if (travelDistance < (initialDistance / 2))
{
speed -= (precision / 50);
if (speed < 0.25)
speed = 0.25;
}
else
{
speed += (precision / 25);
if (speed > 1)
speed = 1;
}
}
if (travelDistance > 30)
{
travelDistance = 30;
if (end.z > current.z)
{
end.z = current.z + 30;
}
else
{
end.z = current.z - 30;
}
}
float i = travelDistance/(maxSpeed*speed);
llMoveToTarget(end,i);
}

GotoFloor (integer floor, key id)
{
llWhisper(0, "Moving to floor#" + (string)floor);
llSetStatus(STATUS_PHYSICS, TRUE);
llLoopSound("ElevatorNoises", 1);

targetFloor = floor;

if (fixedFloorHeight > 0)
{
targetVector = alignment;
targetVector.z = alignment.z + (fixedFloorHeight * floor);
}
else
{
targetVector = alignment;
targetVector.z = llList2Float(floorHeights, floor);
}
llWhisper(0, "At " + (string)targetVector.z + " meters...";);

vector current = llGetPos();
initialDistance = llRound(current.z-targetVector.z);
initialDistance = llAbs(initialDistance);

if (autoSpeed)
{
speed = 0.01;
}

elevate(targetVector);
llSetTimerEvent(precision);
}

reset()
{
llSay(0, "Resetting Elevator...";);
llSetStatus(STATUS_ROTATE_X| STATUS_ROTATE_Y| STATUS_ROTATE_Z, FALSE);

alignment = llGetPos();
llSetStatus(STATUS_PHYSICS, FALSE);
llStopSound();
llListenRemove(numListen);
numListen = llListen( 0, "", "", "" );
}
default
{
state_entry()
{
reset();
}
object_rez(key id)
{
llResetScript();
}
listen(integer a, string n, key id, string m)
{
vector pos;
integer Floor;
float tempFloat;

if (llSubStringIndex(m, "goto floor";) == 0)
{
Floor = (integer)llGetSubString(m, 10, llStringLength(m));
GotoFloor(Floor, NULL_KEY);
}
if (llSubStringIndex(m, "speed";) == 0)
{
tempFloat = (float)llGetSubString(m, 5, llStringLength(m));
if ((tempFloat > 0.001) && (tempFloat <= 1.0))
{
speed = tempFloat;
}
}
if ((m=="elevator reset";) && (id==llGetOwner()))
{
reset();
}
}

timer()
{
vector CurrentPos;
float tempfloat;

CurrentPos = llGetPos();
tempfloat = (CurrentPos.z - targetVector.z);

if (llFabs(tempfloat) < 2)
{
if (llFabs(tempfloat) < 0.05)
{
//Arrived at Floor
llWhisper(0, "Arrived at floor #" + (string)targetFloor);
llSetTimerEvent(0);
llSetStatus(STATUS_PHYSICS, FALSE);
llStopSound();
}
else
{
llMoveToTarget(targetVector,1.0);
}
}
else
{
if (fixedFloorHeight > 0)
{
targetVector = alignment;
targetVector.z = alignment.z + (fixedFloorHeight * targetFloor);
}
else
{
targetVector = alignment;
targetVector.z = llList2Float(floorHeights, targetFloor);
}
elevate(targetVector);
}
}
}
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
04-16-2008 15:58
Wow.. 61.25 Lindens in mass.. that's practically lighter than a feather! :D

Sorry, I just had to. :P

I've heard llMoveToTarget is borked in the current simulator. I am afraid to even rez my train.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-17-2008 03:02
I don't know... I'm actively working on a script that relies heavily on llMoveToTarget() and it seems to be working just fine for me....

I copied the script you posted, and aside from the error due to my lack of the elevator noise sound, it worked just fine.