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_anywhere_script  

teleport_anywhere_script

teleport anywhere script.lsl

Category: Teleport
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for teleport_anywhere_script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. teleport_anywhere_script_1.lsl
1
2
3 //The target location .. change this to where you want to end up (x, y, z)
4 vector gTargetPos = <246, 181, 415>;
5 // Text for the "pie menu"
6 string gSitText="Teleport";
7 // Define channel number to listen to user commands from
8 integer myChannel = 123;
9
10
11 // No need to edit the global variables below
12
13 // Return position for tp object - no need to edit
14 vector gStartPos=<0,0,0>;
15 // Key for avatar sitting on object, if any
16 key gAvatarID=NULL_KEY;
17 // If you don't enable this the teleport object will be left at the destination.
18 integer gReturnToStartPos=TRUE;
19
20
21 // This routine do the actual transport
22 warpPos( vector destpos)
23 { //R&D by Keknehv Psaltery, 05/25/2006
24 //with a little pokeing by Strife, and a bit more
25 //some more munging by Talarus Luan
26 //Final cleanup by Keknehv Psaltery
27 // Compute the number of jumps necessary
28 integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
29 // Try and avoid stack/heap collisions
30 if(jumps > 100 )
31 jumps = 100; // 1km should be plenty
32 list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
33 integer count = 1;
34 while( ( count = count << 1 ) < jumps)
35 rules = (rules=[]) + rules + rules; //should tighten memory use.
36 llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
37 }
38
39 default
40 {
42 {
43 // Put the teleport text in place of the Sit in the pie menu
44 llSetSitText(gSitText);
45 // Read the objects position so it can return to it after teleporting
46 gStartPos = llGetPos();
47 // Sit the avatar on the object
48 llSitTarget(<0,0,1>,ZERO_ROTATION);
49 // Define commands to listen for
50 llListen(myChannel,"","","");
51 }
52
53 on_rez(integer startup_param)
54 {
56 }
57
58 listen(integer chan, string name, key id, string cmd)
59 {
60 if(cmd == "show")
61 {
62 llSetAlpha( 1, ALL_SIDES );
63 }
64 else if(cmd == "hide")
65 {
66 llSetAlpha( 0, ALL_SIDES );
67 }
68 else if(cmd == "reset")
69 {
71 }
72 else if(cmd == "help")
73 {
74 llSay(0, "Usage:");
75 llSay(0, "");
76 llSay(0, "show Make teleporter visible");
77 llSay(0, "hide Make teleporter invisible");
78 llSay(0, "reset Resets teleporter script");
79 llSay(0, "help This text");
80 }
81 }
82
83 changed(integer change){
84 if(change & CHANGED_LINK)
85 {
86 // Find id for avatar sitting on the object
87 gAvatarID = llAvatarOnSitTarget();
88 // If someone sits on it...
89 if(gAvatarID != NULL_KEY)
90 {
91 // Move avatar to destination
92 warpPos(gTargetPos);
93 // Pause for 1 second
94 llSleep(1);
95 // Unsit avatar
96 llUnSit(gAvatarID);
97 // Wait 1 second more
98 llSleep(1);
99 // If teleporter should return to original position....
100 if(gReturnToStartPos)
101 {
102 // ... send object to its start position
103 warpPos(gStartPos);
104 }
105 }
106 }
107 }
108
109 } // END //

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