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_v41  

SimtoSim_PseudoTeleporter_v41

modified by: Donjr Spiegelblatt (May 17, 2012)
add support for:
multi-users of the menu system at the same time
Cancel button when only one menu is used
suppot for comment lines in Data starting with # character
new features:
PrettyButton layout of the buttons in dialogs
combined placeNames, simNames and locationVectors into a two strided list called places

Category: Teleport
By : donjr Spiegelblatt
Created: 2012-05-18 Edited: 2012-05-18
Worlds: Second Life

the Zip file

Download all files for SimtoSim_PseudoTeleporter_v41
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SimtoSim_PseudoTeleporter_v41_1.lsl
Get file # 2. SimtoSim_PseudoTeleporter_v41_2.lsl
1
2 // Modified to use SLURs by Ferd Frederix 6-7-2013
3 // modified by: Donjr Spiegelblatt (May 17, 2012)
4 //add support for:
5 // multi-users of the menu system at the same time
6 // Cancel button when only one menu is used
7 // suppot for comment lines in Data starting with # character
8 //new features:
9 // PrettyButton layout of the buttons in dialogs
10 // combined placeNames, simNames and locationVectors into a two strided list called places
11 // Sheena Desade's Sim-to-Sim Teleporter Script and Notecard (v3.1).
12 // Includes dynamic smart menu and instant teleportation (no confirmation required) via chat link.
13 // Missing sanity checks, so format things correctly!
14 // Public domain (open-source) since April 10, 2012.
15
16 /*
17 This script was made April 10, 2012 by Sheena Desade. It is meant only to be redistributed freely
18 (not ever to be sold)! Leave this header intact; other than those two requirements, do what you
19 will with it. And if you make an improvement, feel free to send me a copy. :-)
20 */
21
22 /* *********************************
23 modified by: Donjr Spiegelblatt (May 17, 2012)
24 add support for:
25 multi-users of the menu system at the same time
26 Cancel button when only one menu is used
27 suppot for comment lines in Data starting with # character
28 new features:
29 PrettyButton layout of the buttons in dialogs
30 combined placeNames, simNames and locationVectors into a two strided list called places
31 ********************************** */
32
33 // Modded by Ferd Frederix on 5-30-2013 to run in OpenSim
34
35
36 // ******** OPTIONAL SETTINGS **********
37 string hoverText = "Sim-to-Sim Pseudo Teleporter - click for destinations.";
38 integer menuWait = 30; // How long to wait for the user to pick a menu choice
39 integer menuChannel = -14469; // what channel for the object to 'listen' on.
40 // You can change this channel as needed,
41 // it's not calling out to an object outside of itself.
42 string menuText = "Please select your destination:";
43 string itemDataNotecard = "Data";
44 // The name of the notecard to read from
45 // ******** END OF OPTIONAL SETTINGS **********
46
47 // ******** SYSTEM SETTINGS - DO NOT MODIFY **********
48 // General variables
49 list menu_users = []; // strided list of menu users
50 // [
51 // integer MENU_user = 0; // key of this menu user, unique one entry per user
52 integer MENU_handle = 1; // listen handle of this users llListen
53 integer MENU_timeout = 2; // creation time of this dialog
54 integer MENU_curList = 3; // the current page for this user
55 // ];
56 integer MENU_stride = 4; // Length of one strided of this list
57
58 // The following are required to read the notecard properly
59 integer notecardLine = 0;
60 key currentDataRequest = NULL_KEY;
61 key notecarduuid = NULL_KEY;
62
63 integer length; // How many menu pages we have
64 list places; // strided list of Placename and Sim/position
65
66 string BLANK = " "; // used for filler space(s) in dialogs
67
68 string Prev = "<< Prev ";
69 string Cancel = "Cancel ";
70 string Next = "Next >> ";
71 list Navigate ; // the full navagation functions
72 // ******** END OF SYSTEM SETTINGS and Globals **********
73
74 list PrettyButtons(list options, list utilitybuttons) // from SchmoDialog
75 {
76 // returns a list formatted to that "options" will start in the top left of a dialog,
77 // and "utilitybuttons" will start in the bottom right
78 list spacers;
79 list combined = options + utilitybuttons;
80 while(llGetListLength(combined) % 3 != 0 && llGetListLength(combined) < 12)
81 {
82 spacers += [BLANK];
83 combined = options + spacers + utilitybuttons;
84 }
85
86 return llList2List(combined, 9, 11)
87 + llList2List(combined, 6, 8)
88 + llList2List(combined, 3, 5)
89 + llList2List(combined, 0, 2);
90 }
91
92 advancedMenu(key user, integer curList)
93 {
94 integer StartTimer = (menu_users == []); // check if the timer needs starting
95 integer p = llListFindList(menu_users,[user]);
96 if(~p) // update the returning user's "creation time and curList"
97 menu_users = llListReplaceList( menu_users, [llGetUnixTime(), curList], p + MENU_timeout, p+MENU_curList);
98 else if(llGetListLength(menu_users) > 63) // make sure a listen is aviable
99 {
100 llInstantMessage(user, "Please try again later the system is currently full!");
101 return;
102 }
103 else // first time menu user open there listen and create there entry
104 menu_users += [user, llListen(menuChannel,"",user,""),llGetUnixTime(), curList];
105
106 list buttons = llList2ListStrided(places,0,-1,2); // make a list of only Places
107 list utility = [Cancel]; // user should always have a Cancel option
108 if(length > 1)
109 {
110 // We have more than one page of places.
111 p = 9 * curList; // Figures out the start of the subsection of places to display
112 buttons = llList2List(buttons, p, p+8); // 'buttons' now has one to nine places
113 utility = Navigate; // give full navigation buttons
114 }
115 buttons = PrettyButtons(buttons, utility);
116 // the 'buttons' list also now has other options besides our Places
117 // and the 'utility' button(s) are always on the bottom row.
118
119 llDialog(user,menuText,buttons,menuChannel); // Sends a dialog to the user with the new improved button list
120 if(StartTimer)
121 llSetTimerEvent(5.0); // how often to check for possible timeouts, low number here would just waste processor time
122 }
123
124 remove(integer index, string message)
125 {
126 // Close this users Listen
127 llListenRemove(llList2Integer(menu_users, index+MENU_handle));
128 // Instant message the message to the user
129 llInstantMessage(llList2Key(menu_users, index), message);
130 // delete there menu_users entry
131 menu_users = llDeleteSubList(menu_users, index, index+MENU_stride-1);
132 if(menu_users == []) // if there are no current users
133 llSetTimerEvent(0.0); // stop the timer
134 }
135
136 default
137 {
138 on_rez(integer param)
139 {
140 llResetScript(); // Resets script on rez
141 }
142
144 {
145 Navigate = [ Prev, Cancel, Next ]; // the full navagation functions
146 llOwnerSay("Initializing...");
147 llOwnerSay("Reading item data...");
148 // we start reading the notecard at line 0, the first line specify our initial request
149 if(llGetInventoryType(itemDataNotecard) == INVENTORY_NOTECARD)
150 {
151 notecardLine=0;
152 currentDataRequest = llGetNotecardLine(itemDataNotecard,notecardLine);
153 }
154 else
155 {
156 state configured; // Handle the condition of no Data notecard
157 }
158 }
159
160 dataserver(key query, string data)
161 {
162 if(query == currentDataRequest) // if we are trying to read the notecard
163 {
164 llOwnerSay(data);
165
166 currentDataRequest = NULL_KEY; // Prevent a bug that occurs with dataserver events.
167 if(data == EOF) // If it the end of the file
168 {
169 // Define how many pages of entries we have in the places list
170 length = llGetListLength(places) / 2;
171 if(length < 12)
172 length = 1;
173 else
174 length = length / 9 + 1;
175 llOwnerSay("Done reading data.");
176 state configured;
177 }
178 else
179 {
180 // **** IMPORTANT: I did not put any sanity checks in here, so you'll need to type
181 // it all correctly, in the format "Store Name | Sim Name @ x/y/z" or it will not
182 // work correctly! ****
183 data = llStringTrim(data, STRING_TRIM); // remove pesky leading and trailing whitespace
184 if(llGetSubString(data,0,0) != "#" && data != "") // lines starting with # are comments
185 {
186 // We're looking for the | and @ symbol in our data line
187 list psv = llParseString2List(data,["|","@"],[]);
188 if(llGetListLength(psv) == 3) // If we found them
189 {
190 // note: Appending the BLANK make Ignore not a key word
191 string place = llStringTrim(llList2String(psv,0), STRING_TRIM)+BLANK;
192 // make sure it NOT a BLANK or one of the navigation entries
193 if(llListFindList(Navigate+[BLANK], [place]) == -1) // these we don't want
194 {
196 // into sim erasing all internal spaces and replacing them with %20... there might be a better way to do this
197
198 // Generate a new temp record entry
199 list tmp = [place, sim+"/"+llStringTrim(llList2String(psv,2), STRING_TRIM)];
200
201 // update entry matching on 'place' or append new entry to end of list
202 integer x = llListFindList(llList2ListStrided(places+tmp,0,-1,2),[place])*2;
203 places = llListReplaceList(places, tmp, x, x+1);
204
205 // We put it here so that it will not add the location unless there are also sim and placeNames.
206 // (donjr) No you put it here as you don't have all the info until this point
207 }
208 }
209 else
210 {
211 integer s = llSubStringIndex(data, "="); // Now we are looking for the = symbol
212 if(~s) // if we find it
213 {
215 // use our tokens to determine which variable we are defining
216 data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM);
217 // use our data to define our chosen variable
218 if(token == "hover_text")
219 hoverText = data;
220 else if(token == "menu_text")
221 menuText = data;
222 else if(token == "menu_channel")
223 menuChannel = (integer)data;
224 else if(token == "selection_wait_time")
225 menuWait = (integer)data;
226 }
227 }
228 }
229 // Get the next line
230 currentDataRequest = llGetNotecardLine(itemDataNotecard, ++notecardLine);
231 }
232 }
233 }
234
235
236 }
237
238 state configured
239 {
240 on_rez(integer param)
241 {
242 llResetScript(); // Resets script on rez
243 }
244
245
246
247
249 {
250 // collects our notecarduuid as soon as we enter this state
251 notecarduuid = llGetInventoryKey(itemDataNotecard);
252 if(hoverText != "none")
253 llSetText(hoverText, <1.0,1.0,1.0>, 1); // if you want hovertext
254 else
255 llSetText("", <1.0, 1.0, 1.0>, 0); // if you do not want hovertext
256 llWhisper(0, "Ready and waiting.");
257 }
258
259 changed(integer change)
260 {
261 // We want to reload the Data notecard if it changed
262 if(change & CHANGED_INVENTORY)
263 {
264 if(notecarduuid != llGetInventoryKey(itemDataNotecard)) // If the change was triggered by saving the NC
265 {
266 llOwnerSay("Notecard change detected, resetting script.");
267 llResetScript(); // resets the script
268 }
269 }
270 }
271
272 timer()
273 {
274 integer dietime = llGetUnixTime() - menuWait;
275 // moving backward through the list/array
276 // allows us to delete records without messing up the index.
277 integer index = llGetListLength(menu_users);
278 while(index)
279 {
280 index -= MENU_stride;
281 if(llList2Integer(menu_users, index+MENU_timeout) < dietime)
282 remove(index, "Menu session timed out.");
283 }
284 }
285
287 {
288 do {
289 --num;
290 advancedMenu(llDetectedKey(num), 0); // Send the user the dialog box, first page
291 } while(num);
292 }
293
294 listen(integer index,string name,key user,string message)
295 {
296 // this is for the script to follow instructions based on what happens with the menu.
297 index = llListFindList(menu_users,[user]);
298 if(~index) // not sure this will ever fail, but proper Bookkeeping requires it
299 {
300 integer curList = llList2Integer(menu_users, index + MENU_curList);
301 if(message == Prev || message == Next || message == BLANK)
302 {
303 if(message == Prev)
304 {
305 if(curList == 0) // If we're on the first page
306 curList = length - 1; // wrap to the last page
307 else // If we're not on page one
308 curList--; // Go backwards a page
309 }
310 else if(message == Next)
311 curList = (curList + 1) % length; // this takes care of the wraping
312 // else if(message == BLANK)
313 // { } // do nothing here user selected a spacer just redisplay the same menu
314 advancedMenu(user, curList); // Give the user the dialog menu
315 }
316 else
317 {
318 if(message == Cancel)
319 remove(index, "Teleport cancelled.");
320 else
321 {
322 // determine which location we are teleporting to
323 integer loc = llListFindList(llList2ListStrided(places,0,-1,2), [message]);
324 if(~loc) // if it's an actual location
325 {
326 loc *= 2; // convert from Record number to index
327 // Give them the link to click
328 message = "http://slurl.com/secondlife/" + llList2String(places, loc+1);
329
330
331
332
333 remove(index, "Click this link to teleport to your target location - "+message);
334 }
335 else // on unknown message just give the dialog back to the user
336 advancedMenu(user, curList); // Give the user the dialog menu
337 }
338 }
339 }
340 }
341 }

SimtoSim_PseudoTeleporter_v41

Notecard Information

Category: Teleport
By : donjr Spiegelblatt
Created: 2012-05-18 Edited: 2012-05-18
Worlds: Second Life

1 'Data' notecard for two sandboxes in Kitely:
2
3 Hover_Text = Multi-Region Pseudo Teleporter: Click for Destinations
4 Menu_Text = Please select your destination:
5 Menu_Channel = 4765
6 Selection_Wait_Time = 30.0
7 SB 1| Kitely%20Merchants%20Sandbox @ 128/128/22
8 SB 2| free%20sandbox%20for%20all%20the%20kitley @ 129/124/22
9
10
11 (template for the locations: Company Name | Region Name @ location x/location y/location z)

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