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?
CODE
// Long distance teleport version 1.3
// ----------------------------------
// 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!
// ------------------------------------------------------------------------
// 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
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);
// 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());
}
}
}
}
}