Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Teleport HUD

Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-14-2008 17:29
Added new entry to the wiki Scripting Library and my user page. Hope everyone else likes it as much as I do. Teleporting can be painless!!!!

Library page:

https://wiki.secondlife.com/wiki/Teleport_HUD

CODE

//Teleport HUD V1.2
//Jesse Barnett
//1/22/08

//One of my first "real" scripts from waaaaaay back when.
//Hopefully users will do more then just use this script. Strided lists and
//manipulating lists are the closest we get to arrays in LSL presently.
//Even with all of the list juggling here, you will be surprised just how many
//destinations you can add.

//A lot of code but this is the only teleporter I have been using for over a year now.
//No notecards or lists to fill out. Very user freindly.
//Wherever you are, just touch the button, hit ""Add" and it will prompt you for the name
//Type what you want to name it in open chat, hit enter and you are done
//It will store the sim name, the name you gave it for the menu buttons and the location
//automatically
//It will only show the destinations for the simulator you are in.
//Pick the destination from the menu, touch the bubble that is rezzed in front of
//you and you will instantly teleport to that spot.
//You can also easily remove destinations by picking ""Remove" in the menu and then
//touching the button name you wish to remove.
//In case you are worried about loosing your destinations, you can also use the
//"List" button to output the list of all destinations from all sims.
//I have never lost the destinations because of sim resets etc.
//Have lost them twice tweaking the script. But adding destinations again is so easy
//it is no problem.

//To use, create a button and attach it to the desired position on your HUD.
//Place this script inside, Put the warp pos script into another object you want
//to rez as the bubble, edit it so that when you left click, you will sit.
//Take the "bubble" back into inventory and then place it in the HUD also.

key owner;
string sim;
list sims;
list dest;
list main_menu;
list menu_options =["Add", "Remove", "Back", "List"];
integer rez_chan;
integer rez_chan_handle;
integer menu_chan;
integer menu_chan_handle;
integer edit_chan = 0;// Could change this to another channel if you want for privacy
//It is only used to enter the destination name when you use "Add"
integer edit_chan_handle;
integer edit_test = FALSE;
vector target;
string tp_object = "bubble";

default {
state_entry(){
owner = llGetOwner();
}
touch_start(integer num_detected) {
menu_chan = (integer) llFrand(-100000 - 99999999) - 100000;
if (sim != llGetRegionName() || edit_test) {
//Don't recalculate if no change to region or an edit
sim = llGetRegionName();
edit_test = FALSE;
main_menu =[];
dest = llListSort(dest, 3, TRUE);//Sorts the list in Strides according to sim
sims = llListSort(sims, 1, TRUE);
integer dest_list_sim_loc = llListFindList(dest,[sim]);
//1st entry in list with the current sim
integer sim_list_sim_loc = llListFindList(sims,[sim]);
string next_sim_name = llList2String(sims, (sim_list_sim_loc + 1));
integer next_sim_loc = (integer) llListFindList(dest,[next_sim_name]) - 1;
//Calculates the last entry in the current sim
main_menu = llList2ListStrided(llDeleteSubList(dest, 0, 0), dest_list_sim_loc, next_sim_loc, 3);
//Now menu list is built only showing destinations that are in the current sim
main_menu = llListSort(main_menu, 1, TRUE);
main_menu = (main_menu =[]) + ["Options"] + main_menu;
}
menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
llSetTimerEvent(20);
llDialog(llDetectedKey(0), "Choose destination or Options to add/remove destinations", main_menu, menu_chan);
}
listen(integer channel, string lm, key id, string message) {
if (llListFindList(main_menu + menu_options,[message]) != -1) {
if (message == "Options") {
llDialog(id, "Pick an option!", menu_options, menu_chan);
}
else if (message == "Back") {
llDialog(id, "Where do you want to go?", main_menu, menu_chan);
}
else if (message == "Add") {
integer b = TRUE;
integer m = TRUE;
b = ((llGetListLength(main_menu)) <= 11);
//Only allows 11 entries per simulator
m = (llGetFreeMemory() >= 1000);
//Make usre we have enough memory to manipulate the lists
if (!b || !m) {
llOwnerSay("You can not add any more destinations");
}
else {
llOwnerSay("What do you want to name this destination?");
llListenRemove(menu_chan_handle);
state add_dest;
}
}
else if (message == "Remove") {
llDialog(id, "Which desination do you want to remove?", main_menu, menu_chan);
state rem_dest;
}
else if (message == "List") {
integer i;
if (llGetListLength(dest) > 0) {
for (i = 0; i < llGetListLength(dest); i += 3) {
string sim_name = llList2String(dest, i);
string name = llList2String(dest, i + 1);
string location = llList2String(dest, i + 2);
llOwnerSay(sim_name + " , " + name + " = " + location);
}
}
else {
llOwnerSay("No Destinations Available.");
}
}
else if (llListFindList(dest,[message]) != -1) {
integer index = llListFindList(dest,[message]);
if (index != -1) {
vector pos = llGetPos();
if (pos.z <= 4095) {
target = (vector) llList2String(dest, index + 1);
rez_chan = (integer) llFrand(100000 - 1000000) - 100000;
llSay(0, "Touch the pumpkin to teleport");
llRezObject(tp_object, llGetPos() + (<1, 0, 1> * llGetRot()), ZERO_VECTOR,
ZERO_ROTATION, rez_chan);
}
else {
llOwnerSay("Too high to teleport. You must be lower then 4096 meters");
}
}
}
}
}
on_rez(integer start_param){
if(owner != llGetOwner()){
llResetScript();
}
}
object_rez(key id){
llWhisper(rez_chan, (string) target);
}
timer() {
llSetTimerEvent(0);
llListenRemove(menu_chan_handle);
llListenRemove(rez_chan_handle);
return;
}
}

state add_dest {
state_entry() {
edit_test = TRUE;
llSetTimerEvent(20);
edit_chan_handle = llListen(edit_chan, "", llGetOwner(), "");
}
listen(integer chan, string name, key id, string msg) {
integer e = llListFindList(sims,[sim]);
if (e == -1) {
sims = (sims =[]) + sims +[sim];
}
vector pos = llGetPos();
dest = (dest =[]) + dest +[sim, msg, pos];
llOwnerSay("Added : " + sim + " , " + msg + " = " + (string) pos);
llListenRemove(edit_chan_handle);
state default;
}
timer() {
llSetTimerEvent(0);
llListenRemove(edit_chan_handle);
llOwnerSay("Timeout. Click TP HUD to start again");
state default;
}
}

state rem_dest {
state_entry() {
edit_test = TRUE;
llSetTimerEvent(20);
menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
}
listen(integer chan, string name, key id, string msg) {
integer d = llListFindList(dest,[msg]);
if (d != -1) {
dest = llDeleteSubList(dest, d - 1, d + 1);
llOwnerSay("Removed : " + msg);
integer f = llListFindList(dest,[sim]);
if (f == -1) {
sims = llDeleteSubList(sims, f, f);
llListenRemove(menu_chan_handle);
state default;
}
llListenRemove(menu_chan_handle);
state default;
}
}
timer() {
llSetTimerEvent(0);
llListenRemove(menu_chan_handle);
llOwnerSay("Timeout. Click TP HUD to start again");
state default;
}
}

CODE

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

warpPos(vector target)
{ //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(target, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 100)
jumps = 100; // 1km should be plenty
list rules =[PRIM_POSITION, target]; //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() {
llSetObjectName("bubble");
}

listen(integer channel, string name, key id, string message) {
target = (vector) message;
llListenRemove(listenId);
llSetText("Touch to teleport", <1, 1, 1 >, 1);
llSitTarget(<0, 0, 0.5 >, ZERO_ROTATION);
}

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

changed(integer change) {
if (change & CHANGED_LINK) {
gAvatarID = llAvatarOnSitTarget();
if (gAvatarID != NULL_KEY) {
warpPos(target);
llDie();
}
}
}
}


Editted to reset if owners change.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-16-2008 19:50
Cleaned up the add_dest code some. So much fun going over OLD code. Yech!!!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
Great Teleporter But
01-22-2008 16:06
hi Jesse Barnett ,fantastic script , but it seems that only i can use the teleporter ,my customers are stuck clicking and no globe is apearing , the hud comes up for them though

is it possible to allow anyone to use it


many thanx
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-22-2008 16:45
From: wholesale Bing
hi Jesse Barnett ,fantastic script , but it seems that only i can use the teleporter ,my customers are stuck clicking and no globe is apearing , the hud comes up for them though

is it possible to allow anyone to use it


many thanx

Editted the script to reset if owners change.

Love positive feedback!!! Thanks!!!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
wholesale Bing
Registered User
Join date: 27 Jun 2007
Posts: 24
sorry if im being annoying
01-22-2008 17:30
can only the owner use the teleport ? as i wanted visitors to use it as well

sorry for being dumb :-)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
01-22-2008 17:55
From: wholesale Bing
can only the owner use the teleport ? as i wanted visitors to use it as well

sorry for being dumb :-)

In this case, yes. It is designed as a personal teleport device and to be worn on one of the HUD attachment points on your screen. You walk around and find a spot you like and store that point as a destination. There are other, more sim freindly ways to do a teleporter that is meant to be rezzed in world.

For a business, any of the menu driven teleporters would work. In that case, since the teleporter isn't "mobile" then you will have to enter the destination coordinates manually into a list or notecard.

This script by Nephenthes Ixchel would be a good place to start:

/15/0a/121162/1.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum