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 SimtoSim_PseudoTeleporter_v31  

SimtoSim_PseudoTeleporter_v31

This is Sheena Desade's Sim-to-Sim Telep...

Category: Teleport
By : Sheena Desade
Created: 2012-04-28 Edited: 2012-04-28
Worlds: Second Life

the Zip file

Download all files for SimtoSim_PseudoTeleporter_v31
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SimtoSim_PseudoTeleporter_v31_1.lsl
1 /*
2 This script was made April 10, 2012 by Sheena Desade. It is meant only to be redistributed freely (not ever to be sold)! Leave this header intact; other than those two requirements, do what you will with it. And if you make an improvement, feel free to send me a copy. :-)
3 */
4
5 // ******** OPTIONAL SETTINGS **********
6 string hoverText = "Sim-to-Sim Pseudo Teleporter - click for destinations.";
7 float menuWait = 30.0; // How long to wait for the user to pick a menu choice
8 integer menuChannel = 0; // what channel for the object to 'listen' on. You can change this channel as needed,
9 // it's not calling out to an object outside of itself.
10 string menuText = "Please select your destination:";
11 string itemDataNotecard = "Data";
12 // The name of the notecard to read from
13 // ******** END OF OPTIONAL SETTINGS **********
14
15 // ******** SYSTEM SETTINGS - DO NOT MODIFY **********
16
17 // General variables
18 integer menu_handler; // what the function that brings up the menu is called
19 integer loc = -1; // -1 = none chosen; 0 = first location, etc.
20 integer length; // How long the placeNames list is, which we base everything else off of
21 integer curList = 1; // The current list number we're on
22 key curUser = NULL_KEY; // The current user's key
23
24 // The following are required to read the notecard properly
25 integer notecardLine;
26 key currentDataRequest;
27 key notecarduuid;
28
29 // These are the lists that hold all of our information
30 list simNames; // The sim names of the places to teleport to
31 list placeNames; // The region names of the places to teleport to
32 list locationVectors; // The position to teleport to
33 // ******** END OF SYSTEM SETTINGS **********
34
35 init() // Setup the dataserver event for future use
36 {
37 llOwnerSay("Reading item data...");
38 notecardLine = 0; // we start reading the notecard at line 0, the first line
39 currentDataRequest = llGetNotecardLine(itemDataNotecard, notecardLine); // specify our initial request
40 }
41
42 advancedMenu(key user, string text, integer channel)
43 {
44 menu_handler = llListen(menuChannel,"","",""); // Lets the object 'hear' the option you choose
45 if(length <= 12) llDialog(user,text,placeNames,channel); // Brings up a simple dialog if you have 12 or less options.
46
47 else // If we have more than 12 options, create a multi-page dialog
48 {
49 list buttons; // Makes a list called 'buttons' that we will use later
50
51 if(curList >= 1) // If we are not on page 0 (shouldn't be possible)
52 {
53 integer temp = (9*curList)-1; // Figures out which locations to display as buttons
54 buttons = llList2List(placeNames, temp-8, temp); // the 'buttons' list now has nine locations
55 // (List2List starts at 0, so we count 0 as 1)
56 buttons = llListInsertList(buttons, ["<< Prev", "Cancel", "Next >>"], temp+1);
57 // the 'buttons' list also now has three other options besides our nine locations
58 // (ListInsertList does NOT start at 0. It starts at 1.)
59 }
60
61 buttons =
62 llList2List(buttons, -3, -1)
63 + llList2List(buttons, -6, -4)
64 + llList2List(buttons, -9, -7)
65 + llList2List(buttons, -12, -10); // Puts our buttons in the logical order, instead of the default reversed one
66
67 llDialog(user,text,buttons,channel); // Sends a dialog to the user with the new improved button list
68
69 }
70 }
71
72 default
73 {
74 on_rez(integer param)
75 {
76 llResetScript(); // Resets script on rez
77 }
78
80 {
81 llOwnerSay("Initializing...");
82 notecarduuid = llGetInventoryKey(itemDataNotecard); // collects our notecarduuid as soon as we enter this state
83 init(); // runs our init function to use with our dataserver function
84 }
85
86 dataserver(key query, string data)
87 {
88 if(query == currentDataRequest) // if we are trying to read the notecard
89 {
90 currentDataRequest = ""; // Prevent a bug that occurs with dataserver events.
91 if(data != EOF) // If it isn't the end of the file
92
93 // **** IMPORTANT: I did not put any sanity checks in here, so you'll need to type
94 // it all correctly, in the format "Store Name | Sim Name @ x/y/z" or it will not
95 // work correctly! ****
96
97 {
98 integer s = llSubStringIndex(data, "@"); // We're looking for the @ symbol in our NC line
99 if(~s) // If we find it
100 {
101 string data1 = llStringTrim(llDeleteSubString(data, s, -1), STRING_TRIM);
102 // this line cuts out and saves everything before the @ symbol to use for the next index
104 // this line erases the @ symbol and temporarily saves the location into a seperate string
105
106 integer s = llSubStringIndex(data1, "|"); // Now we're looking for the pipe symbol in only the
107 // 'data1' variable defined when we were parsing for the @ symbol
108 if(~s) // If we find it (which we should, but we will check later to make sure our lists are
109 // the same length, anyway)
110 {
111 string data2 = llDumpList2String(llParseString2List(llStringTrim(llDeleteSubString(data1, 0, s), STRING_TRIM), [" "], [""]), "%20");
112 // Saves the first part in a temp string, erasing all spaces and replacing them with %20... there might be a better way to do this
113 string data3 = llStringTrim(llDeleteSubString(data1, s, -1), STRING_TRIM);
114 // Saves the second part in a temp string
115
116 simNames += [data2];
117 // copies the temporary string data2 into our simNames list. Could probably combine the two
118 // commands as with locationVectors.
119 placeNames += [data3];
120 // copies the temporary string data3 into our placeNames list. Could probably combine the
121 // two commands, as with locationVectors and simNames.
122 locationVectors += [data4];
123 // this line copies the temporary string into our locationVectors list. We put it here so that it
124 // will not add the locationVector unless there are also sim and placeNames.
125 }
126 }
127
128 else
129 {
130 integer s = llSubStringIndex(data, "="); // Now we are looking for the = symbol
131 if(~s) // if we find it
132 {
134 // use our tokens to determine which variable we are defining
135 data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM);
136 // use our data to define our chosen variable
137
138 if(token == "hover_text")
139 hoverText = data;
140 else if(token == "menu_text")
141 menuText = data;
142 else if(token == "menu_channel")
143 menuChannel = (integer)data;
144 else if(token == "selection_wait_time")
145 menuWait = (float)data;
146 }
147 }
148
149 notecardLine++;
150 // Get the next line
151 currentDataRequest = llGetNotecardLine(itemDataNotecard, notecardLine);
152 }
153
154 else // If it is the End of File
155 {
156 length = llGetListLength(placeNames); // Defines how many entries we have in the placeNames list
157 llOwnerSay("Done reading data.");
158 state configured;
159 }
160 }
161 }
162 }
163
164 state configured
165 {
167 {
168 if(hoverText != "none") llSetText(hoverText, <1.0,1.0,1.0>, 1); // if you want hovertext
169 if(hoverText == "none") llSetText("---", <1.0, 1.0, 1.0>, 0); // if you do not want hovertext
170 llWhisper(0, "Ready and waiting.");
171 loc = -1; // Resets the location to none
172 }
173
174 changed(integer change)
175 {
176 // We want to reload channel notecard if it changed
177 if(change & CHANGED_INVENTORY)
178 {
179 if(notecarduuid != llGetInventoryKey(itemDataNotecard)) // If the change was triggered by saving the NC
180 {
181 llOwnerSay("Notecard change detected, resetting script.");
182 llResetScript(); // resets the script
183 }
184 }
185 }
186
187 timer()
188 {
189 llListenRemove(menu_handler); // remove the listen event
190 llInstantMessage(curUser, "Menu session timed out; choices automatically reset.");
191 llSetTimerEvent(0.0); // removes the timer event, as it's not needed at the moment
192 curList = 1; // reset our page to page one
193 loc = -1; // set our location to none
194 curUser = NULL_KEY; // resets the user to none
195 }
196
197 touch_start(integer total_number)
198 {
199 if(curUser == NULL_KEY || curUser == llDetectedKey(0)) // if there is no user or the toucher is the
200 // current user
201 {
202 curUser = llDetectedKey(0); // records the key of the curent user
203 advancedMenu(curUser, menuText, menuChannel); // Sends the user our dialog box
204 llSetTimerEvent(menuWait); // Sets our timer event so the menu will time out
205 }
206
207 if(curUser != NULL_KEY && curUser != llDetectedKey(0)) // If the toucher is not the current user
208 llInstantMessage(llDetectedKey(0), "Sorry, this terminal is in use. Please wait your turn.");
209 }
210
211 listen(integer channel,string name,key id,string message)
212 //this is for the script to follow instructions based on what happens with the menu.
213 {
214 if(message == "<< Prev")
215 {
216 if(curList <= 1) // If we're on the first page
217 {
218 curList = llCeil((float)length/9); // the current page needs to be changed to the last page, since
219 // we're cycling backwards. We do this by rounding up (to cover any remainders) the length variable
220 // (how many options we have total) divided by nine (since that's the number of buttons we need). 4.000
221 // will always round up to 4 (I think?).
222 advancedMenu(curUser, menuText, menuChannel); // Give them our menu dialog
223 llSetTimerEvent(menuWait); // how long until the menu times out?
224 }
225
226 else // If we're not on page one
227 {
228 curList--; // Go backwards a page
229 advancedMenu(curUser, menuText, menuChannel); // Give them our menu dialog
230 llSetTimerEvent(menuWait); // how long until the menu times out?
231 }
232 }
233
234 else if(message == "Next >>")
235 {
236 if(curList*9 >= length) // if we have cycled through all options in our list
237 {
238 curList = 1; // go to page one
239 advancedMenu(curUser, menuText, menuChannel); // Give the user our dialog menu
240 llSetTimerEvent(menuWait); // how long until the menu times out?
241 }
242
243 else
244 {
245 curList++; // go to the next page
246 advancedMenu(curUser, menuText, menuChannel); // Give the user our dialog menu
247 llSetTimerEvent(menuWait); // how long until the menu times out?
248 }
249 }
250
251 else if(message == "Cancel")
252 {
253 llInstantMessage(curUser, "Teleport cancelled.");
254 curUser = NULL_KEY; // Erase the current user
255 curList = 1; // Put our page back on the first page
256 llListenRemove(menu_handler); // remove our listen event
257 llSetTimerEvent(0.0); //removes the timer event, as it's not needed at the moment
258 }
259
260 else
261 {
262
263 loc = llListFindList(placeNames, (list)message); // determine which location we are teleporting to
264
265 if(loc >= 0) // if it's an actual location
266 {
267 if(hoverText != "none") llSetText("Click the link to teleport", <1.0,1.0,1.0>, 1);
268 // if you want hovertext
269 llInstantMessage(curUser, "Click this link to teleport to your target location - " + "secondlife:///app/teleport/" + llList2String(simNames, loc) + "/" + llList2String(locationVectors, loc)); // Give them the link to click
270 llSetTimerEvent(0.0); // removes the timer event, as it's not needed at the moment
271 llSleep(2.5);
272 curUser = NULL_KEY; // resets our user so others can use the teleporter
273 loc = -1; // reset our location to none
274 curList = 1; // reset our page to one
275 if(hoverText != "none") llSetText(hoverText, <1.0,1.0,1.0>, 1);
276 }
277 }
278 }
279 }

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