Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

No more flying on local teleport?

Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
11-13-2007 03:00
I am trying to eliminate the flying after teleporting in one of the freebie TP scripts. I inserted a very short sleep and cut down on handling of extraneous events. Also made it read the target postion from the object description. Seems to work fine, but a few scripting noob questions:

> I inserted a .15 second sleep before the unsit to stop from flying. Worked fine in my lagfree sim ... would it need to be longer in worse circumstances?

> I noticed I was getting two 'Changed' events every time a TP happens ... is there one for the unsit as well as the sit?

> A person in another thread said that no flying would occur if I just reduced the push on unsit. Can't find a way to do that ... any ideas? Not really very fond of the llSleep solution.

> The previous script reset the target position after every sit. Is there any reason to do this ... prim drift or something?

Pls. ignore debugging llSays, lol:

// Script from NCI free teleport disks
// Modified to decrease flying after teleport
// and read target position from object description

// For best results, make sure teleport destination is far enough away from
// other objects so avatar does not collide after tp (end up flying).
// Setting Z point to .25 meter above actual landing helps.

// Note: destination TP point must be set in object Description line, e.g.
// Description: 169,158,600.25
// There is little error checking; script will not TP av's to 0,0,0, which
// is the value you get if you simply type ascii text into the description instead
// of a vector.
// Max distance that sit target can be away is 300m along any one axis.

vector targetPos; //The target location
integer i;

reset()
{
vector target;
list destination;

i = 0;
destination = llParseString2List(llGetObjectDesc(),[","],[]);
targetPos.x = llList2Float(destination,0);
targetPos.y = llList2Float(destination,1);
targetPos.z = llList2Float(destination,2);
if (targetPos == ZERO_VECTOR) { // user probably typed in a text desc
targetPos = llGetPos();
llSay(0, "Bad destination in object description: format x,y,z";);
}
llSay(0,(string)targetPos);
target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(target, ZERO_ROTATION);
llSetSitText(llGetObjectName());

} // endreset

default
{
state_entry()
{
reset();
}

on_rez(integer startup_param)
{
reset();
}

changed(integer change)
{
if (change & CHANGED_LINK)
{

if (i == 0) { // we get two changed events for each TP
llSay(0,"sit change";);
i = 1;
llSleep(0.15); // delay to avoid flying on landing
llUnSit(llAvatarOnSitTarget());
}
else {
llSay(0,"ignore";);
i = 0;
}

} // end avatar sat
else //some other prim change event
{
reset(); // why not?
}
}
}
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
11-13-2007 05:08
From: Nika Talaj

> I inserted a .15 second sleep before the unsit to stop from flying. Worked fine in my lagfree sim ... would it need to be longer in worse circumstances?

No experience but experimenting would be a good idea. I can't see why you would need a longer sleep for a slower sim though.
From: Nika Talaj

> I noticed I was getting two 'Changed' events every time a TP happens ... is there one for the unsit as well as the sit?

Yes, the changed event occurs because the avatar links and then unlinks to the tp prim, this causes the CHANGED_LINK to flag. You would wish to test for llAvatarOnSitTarget(), if there is a key returned then someone has just sat down, otherwise someone stood up / was llUnSit().
From: Nika Talaj

> A person in another thread said that no flying would occur if I just reduced the push on unsit. Can't find a way to do that ... any ideas? Not really very fond of the llSleep solution.

This script does not contain a push (llPushObject) which might be present on other tp systems (though none that I know of).
From: Nika Talaj

> The previous script reset the target position after every sit. Is there any reason to do this ... prim drift or something?

No reason for reset every tp in this script.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
11-13-2007 06:16
The only thing that timers like llSleep() in SL guarantee you is that the script wil sleep for at least the provided time. Most likely longer in a laggy sim.
Nika Talaj
now you see her ...
Join date: 2 Jan 2007
Posts: 5,449
11-13-2007 08:20
Ah! Thank you both!

llAvatarOnSitTarget() ... llAvatarOnSitTarget() .... *scurries away*