Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Teleport Teleport_Hud_v2  

Teleport_Hud_v2

This is my(Donjr Spiegelblatt) version of Teleport hud v2.lsl

Category: Teleport
By : donjr Spiegelblatt
Created: 2012-06-04 Edited: 2012-06-04
Worlds: Second Life

the Zip file

Download all files for Teleport_Hud_v2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Teleport_Hud_v2_1.lsl
1 // Teleport HUD
2 // Jesse Barnett
3 // 1/16/08
4
5 /* **************************
6 One of my first "real" scripts from waaaaaay back when.
7 Hopefully users will do more than just use this script. Strided lists and
8 manipulating lists are the closest we get to arrays in LSL presently.
9 Even with all of the list juggling here, you will be surprised just how many
10 destinations you can add.
11
12 (donjr: Under MONO it's now 11 sims and 10 entries per sim or 110 max if you use all entries)
13
14 A lot of code but this is the only teleporter I have been using for over a year now.
15 No notecards or lists to fill out. Very user freindly.
16 Wherever you are, just touch the button, hit ""Add" and it will prompt you for the name
17 Type what you want to name it in open chat, hit enter and you are done
18 It will store the sim name, the name you gave it for the menu buttons and the location
19 automatically
20
21 (donjr: While I've been using a number of "teleporters" this one is always close at hand.)
22
23 ******** old way
24 It will only show the destinations for the simulator you are in.
25 Pick the destination from the menu, touch the bubble that is rezzed in front of
26 you and you will instantly teleport to that spot.
27 You can also easily remove destinations by picking ""Remove" in the menu and then
28 touching the button name you wish to remove.
29 In case you are worried about loosing your destinations, you can also use the
30 "List" button to output the list of all destinations from all sims.
31 I have never lost the destinations because of sim resets etc.
32 Have lost them twice tweaking the script. But adding destinations again is so easy
33 it is no problem.
34
35 To use, create a button and attach it to the desired position on your HUD.
36 Place this script inside, Put the warp pos script into another object you want
37 to rez as the bubble, edit it so that when you left click, you will sit.
38 Take the "bubble" back into inventory and then place it in the HUD also.
39 ********** end old way
40
41 *** Donjr Spiegelblatt (new way) as of: 1/3/11
42
43 Add support for a "Backup TP menu" notecard (format is the same as the LISTing output)
44 Allows saving/tranfer of entries from one hud to another.
45
46 Now use RLV command llOwnerSay("@tpto:"...) so you have to have RLV enabled for it to function.
47 But that means NO "bubble" and you can TP even to other sims without prompting.
48
49 Now you can also UP navagate and select another sim group. (support allowed by using RLV)
50
51 If there is no entries for the current 'sim' it starts at the sims level
52 Named teleport Entries are unique to a SIM
53
54 Other fixes to asure proper table handling and index searches
55 and caught a few undefined features that cheeped in unannounced.
56
57 May 29, 2012
58 Change how 'state add_dest' gets the Region Corner for the SIM. Now uses llGetRegionCorner, simpler.
59
60 Added a FLAG 'UseRLV' to switch from Using RLV to Using llMapDestination.
61 Added a Toggle to the Option menu (to toggle above flag), as sometimes a Map is useful instead
62 of a FORCE teleport.
63
64 Cleaned up a little of the 'state' logic,
65 also brought back the default selection as the current sim your in, if tp's exists for it.
66
67 Fixed handling of NO 'dest'ination at all conditions.
68 And selection of list sim in list, there use to be a hard to spot errous behavior.
69 (I have a selection of tp points that I defaultly load and hadn't hit those conditions in a while)
70
71 ******************************************
72 *************************************** */
73
74 integer UseRLV = FALSE; // toggle between RLV tpto and Map Destination
75
76 string sim; // current working sim
77 list sims; // list of sim names only
78 list dest; // strided list with the following stride layout:
79 // [
80 // integer DEST_sim_name = 0; // name of sim associated with this entry
81 integer DEST_name = 1; // name of this entry
82 integer DEST_loc = 2; // absolute location of this tp
83 // ];
84 integer DEST_Stride = 3;
85
86 list main_menu; // current working menu
87 list menu_options =["Add", "Remove", "Back", "List", "Toggle"]; // option menu
88
89 integer menu_chan;
90 integer menu_chan_handle = 0;
91
92 integer edit_chan = 33; // Could change this to another channel if you want for privacy
93 // It is only used to enter the destination name when you use "Add"
94 integer edit_chan_handle = 0;
95
96 // load the "Backup TP menu" note card
97 key NCKey;
98 integer NCLine = 0;
99 string NCName = "Backup TP menu";
100
101 string current_sim = ""; // used by default to track change by other sources
102
103 // these are udateded used by GetCurrent_Sim(). dest_sim_loc is used in part to convert index into pointer
104 integer dest_sim_loc = -1; // start of current sim menu in dest
105 integer dest_end_loc = -1; // end of current sim menu in dest
106 string currentsim = "";
107 list GetCurrent_Sim()
108 {
109 if(dest_sim_loc == -1 || currentsim != sim)
110 {
111 currentsim = sim;
112
113 // Calculates the last entry in the current sim
114 integer loc = llListFindList(sims,[sim]) + 1;
115 // in sims find this sim plus one to find the next name in the list
116 dest_end_loc = llListFindList(dest,[llList2String(sims, loc)]);
117 if(~dest_end_loc) // only subtract 1 only if the entry was found
118 dest_end_loc -= 1; // selection of last sim in list hits the not found condition.
119
120 // 1st entry in list for the current sim
121 dest_sim_loc = llListFindList(dest,[sim]);
122 }
123 // return a list containing only destinations that are in the current selected sim
124 list tmp= llList2ListStrided(llDeleteSubList(dest, 0, 0), dest_sim_loc, dest_end_loc, DEST_Stride);
125 // llOwnerSay("debug GetCurrent_Sim tmp=["+llDumpList2String(tmp,", ")+"]");
126 // llOwnerSay("debug dest_sim_loc="+(string)dest_sim_loc+" dest_end_loc="+(string)dest_end_loc);
127 return tmp;
128 }
129
130 default
131 {
133 {
135 llListenRemove(menu_chan_handle);
136 menu_chan_handle = 0;
137 }
139 {
140 // llOwnerSay("state default");
141 dest_sim_loc = -1; // mark that they need to be gotten again
142 menu_chan = (integer)llFrand(-100000 - 99999999) - 100000;
143 if( dest == [] )
144 state LoadData;
145 current_sim = llGetRegionName();
146 }
147 touch_start(integer num_detected)
148 {
149 llSetColor(<1,0,0>,ALL_SIDES);
150 if(sim != "" || current_sim != llGetRegionName())
151 {
152 sim = llGetRegionName(); // default to the current location
153 if(~llListFindList(sims,[sim]))
154 state Current_Sim;
155 }
156 state select_sim;
157 }
158 }
159
160 state LoadData
161 {
163 {
164 llOwnerSay("Reading notecard...");
166 state select_sim;
167 NCKey = llGetNotecardLine(NCName, NCLine=0);
168 }
169 dataserver(key NC2, string data)
170 {
171 if( NCKey == NC2 )
172 {
173 if( data == EOF )
174 {
175 sims = [];
176 if(dest == [])
177 state select_sim;
178 // else
179 dest = llListSort((dest=[]) + dest, DEST_Stride, TRUE);
180 list tmp = llList2ListStrided(dest,0,-1,DEST_Stride);
181 while(tmp != [])
182 {
183 string wrk = llList2String(tmp,0);
184 tmp = llDeleteSubList((tmp=[])+tmp,0,0);
185 sims += wrk;
186 while(llList2String(tmp,0) == wrk)
187 tmp = llDeleteSubList((tmp=[])+tmp,0,0);
188 }
189 state list_mem;
190 }
191 else
192 {
193 data = llStringTrim(data, STRING_TRIM); // remove those pesky trailing blanks
194 integer pos = llSubStringIndex(data,": ");
195 if( pos > -1 )
196 {
197 data = llGetSubString(data, pos+2,-1); // remove time and object name
198 pos = llSubStringIndex(data," , ");
199 string sim_name = llGetSubString(data, 0, pos-1);
200 integer np = llSubStringIndex(data," = ");
201 string location = llGetSubString(data, np+3, -1);
202 if( llGetSubString(location, -1,-1) == "/" )
203 location = llGetSubString(location, 0,-2);
204 string name = llGetSubString(data, pos+3,np-1);
205 llOwnerSay("sim="+sim_name+" name="+name+" location="+location);
206 dest += [ sim_name, name, location ];
207 }
208 NCKey = llGetNotecardLine(NCName, NCLine++);
209 }
210 }
211 }
212 }
213
214 state select_sim
215 {
217 {
219 llListenRemove(menu_chan_handle);
220 menu_chan_handle = 0;
221 }
223 {
224 sim = "";
225 main_menu = ["Options"] + sims;
226 menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
228 llDialog(llGetOwner(), "Choose Sim or Options to add/remove destinations", main_menu, menu_chan);
229 llSetColor(<1,1,1>,ALL_SIDES);
230 }
231 touch_start(integer num_detected)
232 {
234 llDialog(llGetOwner(), "Choose Sim or Options to add/remove destinations", main_menu, menu_chan);
235 }
236 listen(integer channel, string lm, key id, string message)
237 {
238 if(~llListFindList(main_menu + menu_options,[message]))
239 {
240 if(message == "Options" || message == "Toggle")
241 {
242 if(message == "Toggle")
243 UseRLV = ! UseRLV;
244 string stp = "Map Destination";
245 if(UseRLV)
246 stp = "RLV tpto force";
248 llDialog(llGetOwner(), "Pick an option!\nCurrent tp="+stp, menu_options, channel);
249 }
250 else if(message == "Back")
251 {
253 llDialog(llGetOwner(), "Choose Sim or Options to add/remove destinations", main_menu, channel);
254 }
255 else if(message == "Add")
256 {
257 sim = llGetRegionName();
258 main_menu = ["Options","UP"];
259 if(llListFindList(sims,[sim]) == -1)
260 {
261 if(llGetListLength(main_menu) > 11)
262 {
263 sim = "";
264 llOwnerSay("You can NOT add any more sims");
265 state default;
266 }
267 // add_dest is about to add the first entry for this sim
268 }
269 else
270 main_menu += GetCurrent_Sim(); // current sim selection
271 state add_dest;
272 }
273 else if(message == "Remove")
274 {
275 state rem_sim;
276 }
277 else if(message == "List")
278 {
279 state list_mem;
280 }
281 else
282 {
283 sim = message;
284 state Current_Sim;
285 }
286 }
287 }
288 timer()
289 {
290 state default;
291 }
292 }
293
294 state Current_Sim
295 {
297 {
299 llListenRemove(menu_chan_handle);
300 menu_chan_handle = 0;
301 }
303 {
304 // Now menu list is built only showing destinations that are in the current selected sim
305 main_menu = ["Options","UP"] + llListSort(GetCurrent_Sim(), 1, TRUE);
306
307 menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
309 llDialog(llGetOwner(), "Choose destination or Options to add/remove destinations:\nCurrent selected sim is: "+sim, main_menu, menu_chan);
310 llSetColor(<1,1,1>,ALL_SIDES);
311 }
312 touch_start(integer num_detected)
313 {
315 llDialog(llGetOwner(), "Choose destination or Options to add/remove destinations:\nCurrent selected sim is: "+sim, main_menu, menu_chan);
316 }
317 listen(integer channel, string lm, key id, string message)
318 {
319 if(~llListFindList(main_menu + menu_options,[message]))
320 {
321 if(message == "UP")
322 state select_sim;
323 else if(message == "Options" || message == "Toggle")
324 {
325 if(message == "Toggle")
326 UseRLV = ! UseRLV;
327 string stp = "Map Destination";
328 if(UseRLV)
329 stp = "RLV tpto force";
331 llDialog(llGetOwner(), "Pick an option!\nCurrent selected sim is: "+sim+"\nCurrent tp="+stp, menu_options, channel);
332 }
333 else if(message == "Back")
334 {
336 llDialog(llGetOwner(), "Choose destination or Options to add/remove destinations:\nCurrent selected sim is: "+sim, main_menu, channel);
337 }
338 else if(message == "Add")
339 {
340 state add_dest;
341 }
342 else if(message == "Remove")
343 {
344 state rem_dest;
345 }
346 else if(message == "List")
347 {
348 state list_mem;
349 }
350 else // if(llListFindList(GetCurrent_Sim(),[message]) != -1)
351 {
352 // search within Names in the current SIM group only, Allows names to be unique to a SIM
353 integer index = llListFindList(GetCurrent_Sim(), [message]);
354 if(~index)
355 {
356 // convert sub menu index into dest array pointer
357 index = dest_sim_loc + (index * DEST_Stride);
358 string sHome = llList2String(dest, index + DEST_loc);
359 // llOwnerSay("sHome="+sHome);
360 if(UseRLV)
361 {
362 llOwnerSay("Teleporting");
363 llOwnerSay("@tpto:"+sHome+"=force");
364 }
365 else
366 {
367 // display a map
368 // first convert sHome to a Vector
369 list t = llParseString2List(sHome,["/"],[]);
371 // then turm it into a realative offset
372 pos -= llGetRegionCorner();
374 // then display on map
376 }
377 }
378 state default;
379 }
380 }
381 }
382
383 timer()
384 {
385 state default;
386 }
387 }
388
389 state list_mem
390 {
392 {
393 if(dest == [])
394 llOwnerSay("No Destinations Available.");
395 else
396 {
397 integer stop = llGetListLength(dest);
398 integer i;
399 for (i = 0; i < stop; i += DEST_Stride)
400 {
401 string sim_name = llList2String(dest, i); // + DEST_sim_name
402 string name = llList2String(dest, i + DEST_name);
403 string location = llList2String(dest, i + DEST_loc);
404 llOwnerSay(sim_name + " , " + name + " = " + location);
405 }
406 }
407 state default;
408 }
409 on_rez(integer xxx)
410 {
411 state default;
412 }
413 }
414
415 state add_dest
416 {
417 on_rez(integer xxx)
418 {
419 state default;
420 }
422 {
423 integer b = ((llGetListLength(main_menu)) <= 11);
424 // Only allows 11 entries per simulator
425 integer m = (llGetFreeMemory() >= 1000);
426 // Make sure we have enough memory to manipulate the lists
427 if(!b || !m)
428 {
429 if(!m)
430 llOwnerSay("Out of free working memory no more destinations can be added.");
431 else
432 llOwnerSay("You can NOT add any more destinations to this sim.");
433 state default;
434 }
435 llOwnerSay("Enter the name in the text box or type the destination name on channel /" + (string)edit_chan );
437 edit_chan_handle = llListen(edit_chan, "", llGetOwner(), "");
438 llTextBox(llGetOwner(),"What do you want to name this destination?",edit_chan);
439 }
441 {
442 llSetTimerEvent(0.0);
443 llListenRemove(edit_chan_handle);
444 edit_chan_handle = 0;
445 }
446 listen(integer chan, string name, key id, string msg)
447 {
448 // llOwnerSay("Heard: "+msg);
449 if(llListFindList(sims,[sim]) == -1)
450 sims = llListSort((sims=[]) + sims + [sim], 1, TRUE); // add a new sims entry
451 else
452 {
453 integer i = llListFindList(GetCurrent_Sim(), [msg]);
454 if(~i)
455 {
456 // an entry by that name already exists in this SIM group, so delete it
457 // convert sub menu index into dest array pointer
458 i = dest_sim_loc + (i * DEST_Stride);
459 dest = llDeleteSubList((dest=[])+dest, i, i + DEST_Stride - 1);
460 }
461 }
462 vector vHome = llGetRegionCorner() + llGetPos();
463 dest += [sim, msg, (string)vHome.x+"/"+(string)vHome.y+"/"+(string)vHome.z];
464 dest = llListSort(dest, DEST_Stride, TRUE); //Sorts the list in Strides according to sim
465 llOwnerSay("Added: " + sim + " , " + msg + " = " + (string)vHome.x+"/"+(string)vHome.y+"/"+(string)vHome.z);
466 // llOwnerSay("dest=["+llDumpList2String(dest,", ")+"]");
467 state default;
468 }
469 timer()
470 {
471 llOwnerSay("Timeout. Click TP HUD to start again");
472 state default;
473 }
474 }
475
476 state rem_dest
477 {
478 on_rez(integer xxx)
479 {
480 state default;
481 }
483 {
485 menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
486 llDialog(llGetOwner(), "Which desination do you want to remove?", main_menu, menu_chan);
487 }
489 {
490 llSetTimerEvent(0.0);
491 llListenRemove(menu_chan_handle);
492 menu_chan_handle = 0;
493 }
494 listen(integer i, string name, key id, string msg)
495 {
496 if((i = llListFindList(GetCurrent_Sim(), [msg])) != -1)
497 {
498 // convert sub menu index into dest array pointer
499 i = dest_sim_loc + (i * DEST_Stride);
500 dest = llDeleteSubList((dest=[])+dest, i, i + DEST_Stride - 1);
501 llOwnerSay("Removed : " + msg);
502 if(llListFindList(llList2ListStrided(dest,0,-1,DEST_Stride),[sim]) == -1)
503 {
504 // this was the only entry for this sim also remove it's sims entry.
505 i = llListFindList(sims,[sim]);
506 sims = llDeleteSubList((sims=[])+sims, i, i);
507 }
508 state default;
509 }
510 }
511 timer()
512 {
513 llOwnerSay("Timeout. Click TP HUD to start again");
514 state default;
515 }
516 }
517
518 state rem_sim
519 {
520 on_rez(integer xxx)
521 {
522 state default;
523 }
525 {
527 menu_chan_handle = llListen(menu_chan, "", llGetOwner(), "");
528 llDialog(llGetOwner(), "Which SIM (entries) do you want to remove?", ["Cancel "]+sims, menu_chan);
529 }
531 {
532 llSetTimerEvent(0.0);
533 llListenRemove(menu_chan_handle);
534 menu_chan_handle = 0;
535 }
536 listen(integer i, string name, key id, string msg)
537 {
538 if((i = llListFindList(sims,[msg])) != -1)
539 {
540 sim = msg;
541 GetCurrent_Sim();
542 // we want dest_sim_loc and dest_end_loc updated not the temp list that returned
543 // Now delete the 'sims' entry
544 sims = llDeleteSubList((sims=[])+sims,i,i);
545 // Now delete all the 'dest' entries referencing this sim(msg)
546 dest = llDeleteSubList((dest=[])+dest, dest_sim_loc, dest_end_loc);
547 }
548 state default;
549 }
550 timer()
551 {
552 llOwnerSay("Timeout. Click TP HUD to start again");
553 state default;
554 }
555 }

Back to the Best Free Tools in Second Life and OpenSim.