Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

WarpPos and SetPos - help with long range teleport due to bug

Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
03-21-2007 03:33
Hi there
I'm trying to install a simple long-range tp in my house to get to my skybox. I know that the WarpPos still isn't working as when I tried to use Lisbeth Cohen's script I can only move 10m. Trouble is, my scripting skill is lower than basic so could someone kindly point me in the direction of a script which will move me to a fixed position 650m above me?

I believe I have to use setPos with loops but when I've tried to do this using the LSLwiki I'm confused as to where I put the target vector. And confused about everything to be honest.

Thanks very much for any help!
Biddily
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
03-21-2007 04:01
Replace your old WarpPos function with THIS one

CODE
 warpPos( vector destpos )
{
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
if (jumps > 100 )
{
jumps = 100;
}
list rules = [ PRIM_POSITION, destpos ];
integer count = 1;
while (( count = count << 1 ) < jumps)
{
rules = (rules=[]) + rules + rules;
}
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
if (llVecDist(destpos, llGetPos()) > 0.01)
{
jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
count = 0;
while ( count < jumps)
{
llSetPos(destpos);
count++;
}
}
}


Discussion here: /54/37/171440/1.html
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
Goes sideways not up, doesn't go far
03-21-2007 05:47
Thanks for the reply Winter!. I did what you suggest - amended script herewith (still got my destination vector in for clarity). Put this in a prim, clicked teleport and it took me sideways - not sure exactly how far, definitely not where I wanted to go.

I expect I'm still doing something wrong, but could you tell me what?
Many thanks
Biddily
CODE

// Long distance teleport version 1.2
// ----------------------------------
// Revision History
// 1.1 Lisbeth Hohen
// 1.2 Soen Eber
// (new) Reads from Description
// (mod) less laggy command interface
// (new) floating text
//
// This script is based on other public domain free scripts, so I don't
// take credit for any of the work here.
// Bits and pieces combined by Lisbeth Cohen - plus added show/hide.
//
// The basics of the script is based on Till Sterling's simple teleport
// script, with cross sim transportation routine developed by
// Keknehv Psaltery, modified by Strife Onizuka, Talarus Luan and
// Keknehv Psaltery.
// The transportation functionality is based upon Nepenthes Ixchel's
// 1000m Menu-driven Intra-Sim Teleporter
//
// Thank you to authors who have given me permission to publish this script.
// A special thank you to Keknehv Psaltery for suggesting small improvements!
//
// Realeased as public domain - you are NOT allowed to sell it without the
// permissions of all the authors I've credited above (except those who
// may have left sl at the time)!
// Feel free to use it in freebies and to give it to your friends :-)
//
// Please do not take credit for the work of all those great authors
// mentioned above!
// If you edit the script, please do not change the lines above - thanks!
// ------------------------------------------------------------------------


// Text for the "pie menu"
string gSitText="Teleport";
// Define channel number to listen to user commands from
integer myChannel = 123;

// No need to edit the global variables below

//The target location .. this is set by reading the description
vector gTargetPos = <47.46593, 136.42549, 624.72137>;
// Return position for tp object - no need to edit
vector gStartPos;
// Key for avatar sitting on object, if any
key gAvatarID=NULL_KEY;
// If you don't enable this the teleport object will be left at the destination.
integer gReturnToStartPos=TRUE;
// used for triggering command entry
float elapsed = 0.0;
integer announced;
integer listenHandle;
// remember previous description so script will know to reset
string currentDescription = "";

vector SetDestAndText()
{
string desc;
string arg1 = "";
string arg2 = "";
string arg3 = "";
integer i;
integer j;
float alpha = 0.0;
vector dest;
vector color = <0.0, 0.0, 0.0>;

// Parse Description Text
desc = llGetObjectDesc();
i = llSubStringIndex(desc, ">");
j = llSubStringIndex(desc, ";");
arg1 = llGetSubString(desc, 0, i);
if (j == -1) {
arg2 = llGetSubString(desc, i + 1, llStringLength(desc));
}
else {
arg2 = llGetSubString(desc, i + 1, j - 1);
arg3 = llToUpper(llGetSubString(desc, j + 1, llStringLength(desc)));
}

// Convert to vector and text and text color
dest = (vector)arg1;
if (llSubStringIndex(arg3, "R") == -1) color.x = 0.0;
else color.x = 1.0;
if (llSubStringIndex(arg3, "G") == -1) color.y = 0.0;
else color.y = 1.0;
if (llSubStringIndex(arg3, "B") == -1) color.z = 0.0;
else color.z = 1.0;
if (llSubStringIndex(arg3, "A") == -1) alpha = 1.0;
else alpha = 0.0;

llSetText(arg2, color, alpha);
return(dest);
}
sayHelp()
{
llOwnerSay("Commend Entry: Usage is:");
llOwnerSay("/123 show Make teleporter visible");
llOwnerSay("/123 hide Make teleporter invisible");
llOwnerSay("/123 reset Resets teleporter script");
llOwnerSay("/123 help This text");
llOwnerSay("You have 120 seconds to enter commands before having to touch and hold to re-engage");
announced = TRUE;
}

// This routine do the actual transport
warpPos( vector destpos )
{
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
if (jumps > 100 )
{
jumps = 100;
}
list rules = [ PRIM_POSITION, destpos ];
integer count = 1;
while (( count = count << 1 ) < jumps)
{
rules = (rules=[]) + rules + rules;
}
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
if (llVecDist(destpos, llGetPos()) > 0.01)
{
jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
count = 0;
while ( count < jumps)
{
llSetPos(destpos);
count++;
}
}
}
default
{
state_entry()
{
// Put the teleport text in place of the Sit in the pie menu
llSetSitText(gSitText);
// Read the objects position so it can return to it after teleporting
gStartPos = llGetPos();
// Sit the avatar on the object
llSitTarget(<0,0,1>,ZERO_ROTATION);
// Read teleport destination and signage from description
gTargetPos = SetDestAndText();
// Set Listener Control
listenHandle = llListen(myChannel,"","","");
// Get current description
currentDescription = llGetObjectDesc();
}

on_rez(integer startup_param)
{
llResetScript();
}

touch_start(integer num_detected)
{
if (llDetectedKey(0) == llGetOwner()) {
elapsed = llGetAndResetTime();
announced = FALSE;
}
else {
llSay(0, "Not owner");
}
}
touch(integer num_detected)
{
if ((llDetectedKey(0) == llGetOwner()) && (announced == FALSE)) {
elapsed = llGetTime();
if (elapsed > 2.0) {
if (currentDescription == llGetObjectDesc()) {
llListenControl(listenHandle, TRUE); // ...enable listen
llSetTimerEvent(120);
sayHelp();
}
else {
llOwnerSay("Description has changed - resetting script");
llOwnerSay("You will need to press and hold again to trigger command entry after the script resets");
llResetScript();
}
}
}
}
touch_end(integer num_detected)
{
if (llDetectedKey(0) == llGetOwner()) {
announced = FALSE;
}
}
timer()
{
llOwnerSay("Command timeout");
llSetTimerEvent(0.0);
llListenControl(listenHandle, FALSE); // ...disable listen
}
listen(integer chan, string name, key id, string cmd)
{
if (cmd == "show")
{
llSetAlpha( 1, ALL_SIDES );
}
else if (cmd == "hide")
{
llSetAlpha( 0, ALL_SIDES );
}
else if (cmd == "reset")
{
llResetScript();
}
else if (cmd == "help")
{
sayHelp();
}
}

changed(integer change){
if(change & CHANGED_LINK)
{
// Find id for avatar sitting on the object
gAvatarID = llAvatarOnSitTarget();
// If someone sits on it...
if(gAvatarID != NULL_KEY)
{
// Move avatar to destination
warpPos(gTargetPos);
// Pause for 1 second
llSleep(1);
// Unsit avatar
llUnSit(gAvatarID);
// Wait 1 second more
llSleep(1);
// If teleporter should return to original position....
if (gReturnToStartPos)
{
// ... send object to its start position
warpPos(gStartPos);
}
}
}
}
}
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
03-21-2007 09:30
I put your script in a prim, sat on it, and went shooting towards 0,0,0

There may be a clue in there someplace. check out your datapath, and make sure you're passing the destination vector to warppos.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
Sorry you've lost me there
03-21-2007 14:33
Errm datapath? When you said "your script" you do realise that all I'd done is copied your previous post into somebody else's script - I was amazed it saved without errors, so when you talk about datapaths and destination vectors set to warp drive I am rather out of my depth.

Thanks for the advice anyway, I'll carry on fighting til it works or I give up totally
Biddily
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
03-21-2007 15:18
The problem is your local variable for warpPos - destpos is not set to be your target that you specified earlier.

You need to add the following just below warpPos(vector destpos)

CODE
destpos = gTargetPos;
Biddily Borst
Registered User
Join date: 1 Aug 2006
Posts: 14
Now you're making me feel even more stupid
03-22-2007 14:57
Thanks for your advice Tiarnalalon - I did what you said about putting the line into the script. It took me the same distance sideways in kind-of-bunny hops, and then left the prim behind.

I give up! I've just put a landmark in a prim with the very simple llMapDestination script http://rpgstats.com/wiki/index.php?title=LlMapDestination which is pretty clumsy but means I don't have to go searching through my inventory for the landmark at least.

If anybody can suggest a better way of doing this, I'd be grateful!
Biddily