Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Long distance teleport

Lisbeth Cohen
Registered User
Join date: 4 Jul 2004
Posts: 53
09-20-2006 22:19
Updated to version 1.4 with the changes made by Soen Eber - thank you very much for improving it so much! Also big thanks to Thorn Harbinger for his alternative script.

The only thing I've changed vs. Soen's 1.3 version is to make it work with the new max altitude in object editor (4096m). The original were set up to go max. 1024m, which were done in 100 jumps. This version use 500 jumps to allow for some diagonal movement from ground level up to 4096m.

Added missing semicolons in Soen's notes regarding comment field for tp prim.

Please note Keknehv warn against heap/stack collisions in this part of the source. Don't use more jumps than you absolutely need.

Original script with fix for jump numbers at bottom of post.

----- Soen's notes for v. 1.3: ------

Updated script to include an access mode of public, group, or owner to restrict teleporter use

Script allows owners to set a destination without changing the code, by editing the object description. They may also set how the text over the teleporter is displayed, and limit access.

Format: <vector>;Description;color;access
Example: <43,122,55>;Teleport to my shop;R;G
<vector> must be three numbers surrounded by angle brackets
Description: may be any text. The text will float above the object containing the teleport script
color : sets the color for description
any combination of the letters R,G,B,A
R=Red, G=Green, B=Blue, A=Alpha (turns invisible - so others don't know its a teleport)
multiple values are allowed, for example: RG
access: Set access to Public (P), Group (G), or Owner (O)
Allowable values are P,G, and O

Activating command mode:
Left click and hold for two seconds over the teleport object
Instructions will be displayed and you may give voice commands for a two minute interval
If the teleporting object's description has changed, activating command mode will automatically register the new location and description.

I didn't change any of the license wording because that's not an area I have a good knowledge on - could someone mod this appropriately, please?

----- Lisbeth's notes for v. 1.1: ------

This is something I cooked together from other free scripts found at this forum. Just put it into a prim and sit on it to teleport - pretty standard. If you move the prim you'll have to reset the script so it will remember its new home position.

Thanks to original authors for their great work and permitting me to publish this!

----------------------------------------------------------------------------------------------------

CODE

// Long distance teleport version 1.4
// ----------------------------------
// If you edit the script, please write down changes to this section as well
// as comment in source - thank you!
//
// Changelog
// -------------
// Version 1.4
// Slightly improved by Lisbeth from Soen's 1.3 version,
// increased number of jumps from the original 100 to 500
//
// Versions 1.2 and 1.3
// Modified and expanded by Soen Eber - see separate comments below.
//
// Versions 1.0 and 1.1
// Bits and pieces combined by Lisbeth Cohen - plus added show/hide.
// This script is based on other public domain/free scripts, so I don't
// take credit for any of the work here.
//
// ------------------------------------------------------------------------
//
// 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,
// and to Soen Eber for improving it and making it so much more user friendly!
//
// Please do not take credit for the work of all those great authors
// mentioned above!
//
// Released 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 :-)
//
// Proper licensing text still needed - anyone want to take care of this...?
//
// ------------------------------------------------------------------------

// This script may now be entirely configured from the object's description, eliminating the need
// to modify code. Arguments are: dest;title;color;access
// dest Destination, expressed as a vector. Example: <23,5,262>
// title This is what is displayed in floating text over the teleport prim
// color Sets color title: any combination of R, G, B, & A. R=Red, G=Green, B=Blue, A=Alpha.
// colors combine, for example RB makes the title pink while RGB makes the title white
// setting A (Alpha) makes the title invisible.
// If no color information is supplied title color will be black
// access Determines who may use the teleport: Use P (Public), G (Group), or O (Owner only)

// 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 = <0.0, 0.0, 0.0>;
//The access mode; P=Public, G=Group only, O=Owner only - read from description
string allowed_access = "O";
// 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 = "";

Parse_Description()
{
string desc;
string arg;
float alpha = 0.0;
vector color = <0.0, 0.0, 0.0>;

desc = llGetObjectDesc();
list desc_list = llParseString2List(desc, [";"], []);

arg = llList2String(desc_list, 0);
gTargetPos = (vector)llList2String([arg], 0);

string text = llList2String(desc_list, 1);

arg = llList2String(desc_list, 2);
if (llSubStringIndex(arg, "R") == -1) color.x = 0.0;
else color.x = 1.0;
if (llSubStringIndex(arg, "G") == -1) color.y = 0.0;
else color.y = 1.0;
if (llSubStringIndex(arg, "B") == -1) color.z = 0.0;
else color.z = 1.0;
if (llSubStringIndex(arg, "A") == -1) alpha = 1.0;
else alpha = 0.0;
llSetText(text, color, alpha);

allowed_access = llToUpper(llList2String(desc_list, 3));
if (llSubStringIndex("PGO", allowed_access) == -1) {
llSay(0, "Unrecognized access mode '" + allowed_access + "' found in description");
llSay(0, "Allowed access modes are P, G, or O (Public, Group, Owner)");
llSay(0, "Defaulting to owner access only");
allowed_access = "O";
}
}
integer allowed(key agent)
{
if (allowed_access == "P") return TRUE;
if (allowed_access == "G") {
if (llSameGroup(agent) == TRUE) return TRUE;
if (agent == llGetOwner()) return TRUE; // owner always gets to teleport
}
if (allowed_access == "O" && (agent == llGetOwner())) return TRUE;
return FALSE;
}
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)
{ //R&D by Keknehv Psaltery, 05/25/2006
//with a little pokeing by Strife, and a bit more
//some more munging by Talarus Luan
//Final cleanup by Keknehv Psaltery
// Compute the number of jumps necessary
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
// Increased to make use of the new object editor altitude limit of 4096m
if (jumps > 500 )
jumps = 500; // 5km should be plenty
list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, 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, title, title color, access mode
Parse_Description();
// 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) {
if (allowed(gAvatarID) == TRUE) {
warpPos(gTargetPos);
llSleep(1);
llUnSit(gAvatarID);
llSleep(1);
if (gReturnToStartPos) {
warpPos(gStartPos);
}
}
else {
llSleep(0.5); // llUnSit works better with this delay
llSay(0, "Sorry, not allowed to use!");
llUnSit(llAvatarOnSitTarget());
}
}
}
}

}


----------------------------------------------------------------------------------------------------

Here's the original script too, in case someone need it. Also fixed with 500 jumps.

----------------------------------------------------------------------------------------------------
CODE

// Long distance teleport version 1.1
// ----------------------------------
// 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!
//
// 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!
// ------------------------------------------------------------------------


//The target location .. change this to where you want to end up (x, y, z)
vector gTargetPos = <246, 181, 415>;
// 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

// Return position for tp object - no need to edit
vector gStartPos=<0,0,0>;
// 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;


// This routine do the actual transport
warpPos( vector destpos)
{ //R&D by Keknehv Psaltery, 05/25/2006
//with a little pokeing by Strife, and a bit more
//some more munging by Talarus Luan
//Final cleanup by Keknehv Psaltery
// Compute the number of jumps necessary
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 500 )
jumps = 500; // 5km should be plenty
list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, 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);
// Define commands to listen for
llListen(myChannel,"","","");
}

on_rez(integer startup_param)
{
llResetScript();
}

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")
{
llSay(0, "Usage:");
llSay(0, "");
llSay(0, "show Make teleporter visible");
llSay(0, "hide Make teleporter invisible");
llSay(0, "reset Resets teleporter script");
llSay(0, "help This text");
}
}

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);
}
}
}
}

}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
09-21-2006 22:34
/54/24/138989/1.html
_____________________
i've got nothing. ;)
Thorn Harbinger
Registered User
Join date: 28 Oct 2005
Posts: 2
Another TP Script
03-07-2007 19:25
CODE
integer totalDest = 4;
vector dest1 = <216.150.22>;
vector dest2 = <225.191.27>;
vector dest3 = <161.200.22>;
vector dest4 = <>;
string dest1_name = "Thorn";
string dest2_name = "M & J";
string dest3_name = "Craig";
string dest4_name = "";
string dest1_desc = "Dance Party";
string dest2_desc = "Party Porch";
string dest3_desc = "Sex Dungeon";
string dest4_desc = "";
integer currentDestNum = 1;
vector currentDest;
string currentDestName;
string currentDestDesc;
rotate_to_zero()
{
llSetRot(<0,0,0,0>);
}
setDestination()
{
if (currentDestNum == 1)
{
currentDest = dest1;
currentDestName = dest1_name;
currentDestDesc = dest1_desc;
}
else if (currentDestNum == 2)
{
currentDest = dest2;
currentDestName = dest2_name;
currentDestDesc = dest2_desc;
}
else if (currentDestNum == 3)
{
currentDest = dest3;
currentDestName = dest3_name;
currentDestDesc = dest3_desc;
}
else if (currentDestNum == 4)
{
currentDest = dest4;
currentDestName = dest4_name;
currentDestDesc = dest4_desc;
}

vector pos = llGetPos();
vector offset = currentDest - pos;

llSitTarget(offset, ZERO_ROTATION);

string hoverText = "TELEPORT TO:\n"+currentDestName+"\n"+currentDestDesc+"\n\.\n(click to choose destination)";
llSetText(hoverText,<0,1,0>,1);
}

default
{
state_entry()
{
rotate_to_zero();
setDestination();
llSetSitText("Teleport");
}
on_rez(integer num)
{
llResetScript();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
llMessageLinked(LINK_SET, 0, "teleporting", "");
llUnSit(llAvatarOnSitTarget());
}
}
}
touch_start(integer total_number)
{
currentDestNum += 1;
if (currentDestNum > totalDest) currentDestNum = 1;
rotate_to_zero();
setDestination();
}
}
Pamela Galli
Registered User
Join date: 1 Dec 2007
Posts: 47
02-22-2008 16:55
I pasted this into a script and it says 0,0 syntax error. I know almost nothing about scripting so I can't figure out what to change.

CODE
// Long distance teleport version 1.1
// ----------------------------------
// 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!
//
// 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!
// ------------------------------------------------------------------------


//The target location .. change this to where you want to end up (x, y, z)
vector gTargetPos = <246, 181, 415>;
// 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

// Return position for tp object - no need to edit
vector gStartPos=<0,0,0>;
// 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;


// This routine do the actual transport
warpPos( vector destpos)
{ //R&D by Keknehv Psaltery, 05/25/2006
//with a little pokeing by Strife, and a bit more
//some more munging by Talarus Luan
//Final cleanup by Keknehv Psaltery
// Compute the number of jumps necessary
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 100 )
jumps = 100; // 1km should be plenty
list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, 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);
// Define commands to listen for
llListen(myChannel,"","","");
}

on_rez(integer startup_param)
{
llResetScript();
}

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")
{
llSay(0, "Usage:");
llSay(0, "");
llSay(0, "show Make teleporter visible");
llSay(0, "hide Make teleporter invisible");
llSay(0, "reset Resets teleporter script");
llSay(0, "help This text");
}
}

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);
}
}
}
}

}