Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Personal Teleporter

Teneo Hope
Registered User
Join date: 28 Dec 2004
Posts: 16
08-12-2005 03:58
This is a little tool I cooked up to take advantage of the llSitTarget Teleport Hack in a convient way.

Essentually one can setup a number of teleport locations each identified by a string of the users choosing. The user then can

simply say that identifier on a chat channel and an object will be rezzed that the user can sit on to take them to the desired

location.

The script will require two objects, a controller and a teleporter.

controller object
The controller object is attached to the user and contains the teleport controller script and the teleporter object.

teleporter object
This is a temporary object that will rez when need to teleport a user to a certain target then delete's itself. This object

contains the teleporter object script.

Example Commands:

/1 tp help - displays help information
/1 tp add destination_id - add's a new location named destination_id
/1 tp remove destination_id - removes a location named destination_id
/1 tp list - lists all current destinations
/1 tp destination_id - creates a teleport object to the requested destination

Teleport Controller Script
CODE

//
// SCRIPT: Teleport Controller Script
// CREATED BY: Teneo Hope
//

list destinations; // List of destination id's and their associated vectors

integer listenId; // Listener ID

string startingCommand = "tp"; // this must be said before any option (e.g /CHANNEL [starting_command] [option] [arguement])

string objectName = "Object"; // Name of object to rez that will teleport the avatar

integer CHANNEL = 1; // Chat channel to listen on

default
{
state_entry()
{
// Setup the listener
llListenRemove(listenId);
listenId = llListen(CHANNEL,"",llGetOwner(),"");
}

attach(key id)
{
// Setup the listener
llListenRemove(listenId);
listenId = llListen(CHANNEL,"",llGetOwner(),"");
}

listen(integer channel, string name, key id, string message)
{
// Parse out the request for ease of use
list params = llParseString2List(message,[" "],[]);

if(llList2String(params,0) == startingCommand)
{
if(llList2String(params,1) == "help")
{
// Display help information
llOwnerSay("Portal Help");
llOwnerSay("/" + (string)CHANNEL + " " + startingCommand + " add destination_id - Adds a new portal destination of the id destination_id");
llOwnerSay("/" + (string)CHANNEL + " " + startingCommand + " remove destination_id - Deletes a portal destination of the id destination_id");
llOwnerSay("/" + (string)CHANNEL + " " + startingCommand + " list - List all current destinations");
llOwnerSay("/" + (string)CHANNEL + " " + startingCommand + " destination_id - Create a portal stone to the selected destination.");
}
else if (llList2String(params,1) == "add")
{
// Add a new destination
if (llList2String(params,2) != "")
{
vector pos = llGetPos();
destinations = destinations + [llList2String(params,2), pos];
llOwnerSay("Added Destination: " + llList2String(params,2) + " => " + (string)pos);
}
}
else if (llList2String(params,1) == "remove")
{
// Remove a user specified destination
if (llList2String(params,2) != "")
{
integer index = llListFindList(destinations, [llList2String(params,2)]);
if(index != -1)
{
destinations = llDeleteSubList(destinations, index, index + 1);
llOwnerSay("Removed Destination: " + llList2String(params,2));
}
}
}
else if (llList2String(params,1) == "list")
{
// List all destinations available
integer i;
if(llGetListLength(destinations) > 0)
{
for (i = 0; i < llGetListLength(destinations); i+=2)
{
string name = llList2String(destinations, i);
string loc = llList2String(destinations, i+1);
llOwnerSay(name + " => " + loc);
}
}
else
{
llOwnerSay("No Destinations Available.");
}
}
else if (llList2String(params,1) != "")
{
integer index = llListFindList(destinations, [llList2String(params,1)]);
if(index != -1)
{
vector target = (vector)llList2String(destinations, index+1);
integer channel = (integer)llFrand(9999999 - 9000000) + 9000000;
vector pos = llGetPos();

if(llVecDist(pos, target) < 300.0)
{
// Create a teleporter object
// Send it the randomly generated channel to listen on so we can tell it what location to target
llRezObject(objectName, (pos + llRot2Fwd(llGetRot()) + <0,0,1>), ZERO_VECTOR, ZERO_ROTATION, channel);
llWhisper(channel, (string)target);
}
else
{
// Teleporters have a limited range of 300 meters if the distance
// to the destination is beyond that limit don't do anything.
llOwnerSay("Destination is out of range.");
}

}
}
}
}
}


Teleporter Object Script

CODE

//
// SCRIPT: Teleporter Object Script
// CREATED BY: Teneo Hope
//

vector target; // The location the av will be teleported to.
integer listenId; // Listener ID

default
{
listen(integer channel, string name, key id, string message)
{
// Target obtained
target = (vector)message;
llListenRemove(listenId);
state activate;
}

on_rez(integer start_param)
{
// When this object rezzes setup a listener to get the target
listenId = llListen(start_param,"","","");
}
}

state activate
{
state_entry()
{
// Activate capability to teleport av to target
llSetSitText("Teleport");
llSitTarget((target - llGetPos()) * (ZERO_ROTATION / llGetRot()),ZERO_ROTATION / llGetRot());
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();
if(av != NULL_KEY)
{
// Teleport the avatar
llUnSit(av);
llPushObject(av,<0,0,10>,ZERO_VECTOR,FALSE);
llDie();
}
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
08-20-2005 12:05
/54/6e/58430/1.html
_____________________
i've got nothing. ;)
a lost user
Join date: ?
Posts: ?
08-26-2005 19:41
Wow Teneo, awesome concept. I like the idea of this one alot. =P