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
Translator Universal_Google_Translator  

Universal_Google_Translator

The device consists of 3 key scripts, wi...

Category: Translator
By : Hank Ramos
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Universal_Google_Translator
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Universal_Google_Translator_1.lsl
Get file # 2. Universal_Google_Translator_2.lsl
Get file # 3. Universal_Google_Translator_3.lsl
1 //Universal Translator
2 //Version 1.9.0
3 //November 12, 2009
4 //LSL Script copyright 2006-2009 by Hank Ramos
5 //Web Server Services powered by Google
6
7 //Variables
8 list agentsInTranslation;
9 list agentsInTranslationOptions;
10 list requestList;
11 integer listenID;
12
13 integer isMaster = 1;
14 integer autoLanguage = TRUE;
15 integer enabled = FALSE;
16 integer showTranslation = FALSE;
17 integer tranObjects = TRUE;
18
19 integer lastHeartBeat;
20 list languageCodes = [
21 "zh-CN", "zh-TW", "hr",
22 "bg", "be", "ca",
23 "af", "sq", "ar",
24
25 "tl", "fr", "gl",
26 "fi", "en", "et",
27 "cs", "da", "nl",
28
29 "id", "ga", "it",
30 "hi", "hu", "is",
31 "de", "el", "iw",
32
33 "mt", "no", "fa",
34 "lt", "mk", "ms",
35 "ja", "ko", "lv",
36
37 "sl", "es", "sw",
38 "ru", "sr", "sk",
39 "pl", "pt-PT", "ro",
40
41 "yi", "", "",
42 "uk", "vi", "cy",
43 "sv","th", "tr"];
44
45 list translators;
46 list sayCache;
47 list sayCachePrivate;
48 integer priorityNumber;
49 integer priorityNumListenID;
50 integer isInitialized = FALSE;
51 string options;
52
53 //Options
54 //integer debug = TRUE;
55 integer broadcastChannel = -9999999; //note this is not the channel used by the HR Universal Translator
56 string password = "password"; //note this is not the password used to encrypt comms of the HR Universal Translator
57 integer version = 190;
58 sendIM(key id, string str)
59 {
61 {
62 llMessageLinked(LINK_ALL_CHILDREN, 85234119, str, id);
63 }
64 else
65 {
66 llMessageLinked(LINK_THIS, 85304563, str, id);
67 }
68 }
69
70 sendTextBatch(integer channel, string sendText)
71 {
72 sendText = llXorBase64StringsCorrect(llStringToBase64(sendText), llStringToBase64(password));;
73 while(llStringLength(sendText) > 508) //If string is 509 characters or longer
74 {
75 llSay(channel, llGetSubString(sendText, 0, 507)); //send 508 character chunk
76 sendText = llGetSubString(sendText, 508, -1); //delete 508 character chunk
77 }
78 llSay(channel, sendText); //send out any remainder chunk or original chunk
79 if(llStringLength(sendText) == 508)
80 llSay(channel, (string)(channel*4958654));
81 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<0.25, 0, 0.25>, "");
82 }
83
84 string receiveTextBatch(key id, string message)
85 {
86 integer listPos;
87 string tempString = "";
88
89 listPos = llListFindList(sayCache, [id]);
90 if(listPos >= 0)
91 {
92 while(listPos >= 0)
93 {
94 tempString = tempString + llList2String(sayCache, listPos + 1);
95 sayCache = llDeleteSubList(sayCache, listPos, listPos + 1);
96 listPos = llListFindList(sayCache, [id]);
97 }
98 message = tempString + message;
99 }
100 message = llBase64ToString(llXorBase64StringsCorrect(message, llStringToBase64(password)));
101 return message;
102 }
103 string receiveTextBatchPrivate(key id, string message)
104 {
105 integer listPos;
106 string tempString = "";
107
108 listPos = llListFindList(sayCachePrivate, [id]);
109 if(listPos >= 0)
110 {
111 while(listPos >= 0)
112 {
113 tempString = tempString + llList2String(sayCachePrivate, listPos + 1);
114 sayCachePrivate = llDeleteSubList(sayCachePrivate, listPos, listPos + 1);
115 listPos = llListFindList(sayCachePrivate, [id]);
116 }
117 message = tempString + message;
118 }
119 message = llBase64ToString(llXorBase64StringsCorrect(message, llStringToBase64(password)));
120 return message;
121 }
122 updateTranslatorList()
123 {
124 integer x;
125 integer listLength;
126 list newList;
127 string tempString;
128 integer newMaster;
129
130 //Scan and remove translators not in the area
131 for (x = 0; x < llGetListLength(translators); x += 2)
132 {
133 tempString = llList2String(llGetObjectDetails(llList2Key(translators, x + 1), [OBJECT_POS]), 0);
134 if((llVecDist(llGetPos(), (vector)tempString) <= 20.0) && (tempString != ""))
135 newList += llList2List(translators, x, x + 1);
136 }
137 translators = newList;
138
139 listLength = llGetListLength(translators);
140 llMessageLinked(LINK_THIS, 65635544, (string)listLength, "");
141
142 if(listLength == 0)
143 {
144 newMaster = 1;
145 }
146 else
147 {
148 if(enabled)
149 {
150 newMaster = 2;
151 for (x = 0; x < llGetListLength(translators); x += 2)
152 {
153 //llOwnerSay("Checking Priority Number(" + (string)priorityNumber + "): " + (string)llList2Integer(translators, x));
154 if(llList2Integer(translators, x) > priorityNumber)
155 {
156 newMaster = 0;
157 }
158 }
159 }
160 else
161 {
162 newMaster = 0;
163 }
164 }
165
166 if((isMaster > 0) && (newMaster == 0))
167 {
168 //We are being demoted from master to slave
169 //Flush agentsInTranslation to master
170 if(llGetListLength(agentsInTranslation) > 0)
171 {
172 //Demotion Dump of agentsInTranslation to Master
173 sendTextBatch(broadcastChannel, llList2CSV([1003, llList2CSV(agentsInTranslation)]));
174 if(isInitialized == FALSE) return;
175 sendTextBatch(broadcastChannel, llList2CSV([1004, options])); //error
176 }
177 llListenRemove(listenID);
178 }
179 if((isMaster == 0) && (newMaster > 0))
180 {
181 llListenRemove(listenID);
182 listenID = llListen(0, "", "", "");
183 }
184 isMaster = newMaster;
185 llMessageLinked(LINK_THIS, 34829304, (string)isMaster, "");
186 }
187
188 sendHeartbeat()
189 {
190 updateTranslatorList();
191 sendTextBatch(broadcastChannel, llList2CSV([1001, priorityNumber]));
192
193 //Broadcast agentList to Slaves
194 if(isMaster == 2)
195 {
196 sendTextBatch(broadcastChannel, llList2CSV([1002, llList2CSV(agentsInTranslation)]));
197 }
198
199 }
200
201 //Functions
202 checkThrottle(integer num, string msg, list params)
203 {
204 integer x;
205 integer maxCount;
206 float oldTime;
207 float sleepTime;
208 list newList;
209 key returnValue;
210 integer channelToSpeak;
211
212 //loop though list and remove items older than 25 seconds
213 for (x = 0; x < llGetListLength(requestList); x += 1)
214 {
215 oldTime = llList2Float(requestList, x);
216 //Construct new list with only times less than 25 seconds
217 if((llGetTime() - oldTime) <= 25.0)
218 newList += oldTime;
219 }
220 requestList = newList;
221
222 x = llGetListLength(requestList);
223
224 //Shunt all translations to linked translators if master
225 if(isMaster == 2)
226 {
227 if(num == 0)
228 {
229 //Send HTTP request to other translator
230 //Send out Request to Random Translator Channel
231
232 channelToSpeak = llList2Integer(llListRandomize(llList2ListStrided(translators, 0, -1, 2), 1), 0);
233 if(channelToSpeak > 0)
234 {
235 sendTextBatch(channelToSpeak, llList2CSV([num, llList2CSV(params)]) + "~" + msg);
236 return;
237 }
238 }
239 }
240
241 if(x == 19)
242 {
243 sleepTime = 25.0 - (llGetTime() - llList2Float(requestList, 0));
244 if(sleepTime > 0)
245 {
246 llSleep(sleepTime);
247 }
248 requestList = llDeleteSubList(requestList, 0, 0);
249 }
250
251 if(num == 0)
252 {
253 msg = "translate?v=1.0&q=" + msg;
254 }
255 else
256 msg = "detect?v=1.0&q=" + msg;
257
258 requestList += llGetTime();
259 returnValue = llHTTPRequest("http://ajax.googleapis.com/ajax/services/language/" + msg, [HTTP_METHOD, "GET", HTTP_MIMETYPE, "plain/text;charset=utf-8"], " ");
260
261 if(returnValue != NULL_KEY)
262 {
263 if(num == 0)
264 llMessageLinked(LINK_THIS, 235365342, llList2CSV(params), returnValue);
265 else
266 llMessageLinked(LINK_THIS, 235365343, llList2CSV(params), returnValue);
267 }
268 else
269 {
270 llSleep(40.0); //Something has gone horribly wrong, sleep 40 seconds to clear throttle
271 }
272 }
273
274 string checkLanguage(string tempString)
275 {
276 if(llGetSubString(tempString, 0, 1) == "zh") tempString = "zh-CN";
277 else if(tempString == "und") tempString = "el";
278 else if(llListFindList(languageCodes, [tempString]) < 0) tempString = "";
279 tempString = llGetSubString(tempString, 0, 1);
280 return tempString;
281 }
282 addAgent(key id, string language, integer recheckLangauge)
283 {
284 integer listPos;
285 integer listPosID;
286 integer idNum;
287 string tempString;
288
289 listPos = llListFindList(agentsInTranslation, [id]);
290 if(listPos < 0)
291 {
292 while(listPosID >= 0)
293 {
294 idNum = llRound(llFrand(2000000)) + 1;
295 listPosID = llListFindList(agentsInTranslation, [idNum]);
296 }
297 agentsInTranslation += [id, language, recheckLangauge, idNum];
298 llMessageLinked(LINK_THIS, 64562349, language, id);
299 }
300 else
301 agentsInTranslation = llListReplaceList(agentsInTranslation, [language, recheckLangauge], listPos + 1, listPos + 2);
302 }
303
304 string addNewAgent(key id)
305 {
306 string speakerLanguage;
307
309 {
310 speakerLanguage = checkLanguage(llGetAgentLanguage(id));
311 if(speakerLanguage == "")
312 {
313 speakerLanguage = "en";
314 addAgent(id, speakerLanguage, TRUE);
315 }
316 else
317 {
318 addAgent(id, speakerLanguage, FALSE);
319 }
320 }
321 return speakerLanguage;
322 }
323
324 key getAgentKey(integer agentID)
325 {
326 integer listPos = llListFindList(agentsInTranslation, [agentID]);
327 if(listPos < 0)
328 {
329 return "";
330 }
331 else
332 {
333 return llList2Key(agentsInTranslation, listPos - 3);
334 }
335 }
336 processHTTPResponse(integer type, string body, list params)
337 {
338 integer listPos;
339 list recepientList;
340 key recepientID;
341 string recepientLanguage;
342 string languagePair;
343 key speakerID;
344 string speakerName;
345 string speakerLanguage;
346 string translatedText;
347 string tempString;
348 integer x;
349 integer speakerLanguageReliable;
350 float speakerLanguageConfidence;
351 list tempList;
352
353 //===================
354 //Process Translation
355 //===================
356 if(type == 0)
357 {
358 speakerID = llList2Key(params, 1);
359 speakerName = llKey2Name(speakerID);
360 if(speakerName == "")
361 speakerName = llList2String(llGetObjectDetails(speakerID, [OBJECT_NAME]), 0);
362
363 recepientList = llParseString2List(llList2String(params, 2), ["@"], []);
364 tempList = llParseStringKeepNulls(llList2String(params, 3), ["|"],[]);
365 recepientLanguage = llList2String(tempList, 1);
366 languagePair = llDumpList2String(tempList, ">>");
367
368 //Perform Text Cleanup
369 x = llSubStringIndex(body, "\",\"detectedSourceLanguage\":\"");
370 if(x >= 0)
371 {
372 translatedText = llGetSubString(body, llSubStringIndex(body, "{\"translatedText\":\"") + 18, x);
373 speakerLanguage = checkLanguage(llGetSubString(body, x + 28, llSubStringIndex(body, "\"}, \"responseDetails\":") - 1));
374
375 listPos = llListFindList(agentsInTranslation, [speakerID]);
376 if(listPos >= 0)
377 {
378 if(speakerLanguage != llList2String(agentsInTranslation, listPos + 1))
379 agentsInTranslation = llListReplaceList(agentsInTranslation, [TRUE], listPos + 2, listPos + 2); //Mark for recheck of actual spoken language.
380 }
381 }
382 else
383 {
384 translatedText = llGetSubString(body, llSubStringIndex(body, "{\"translatedText\":\"") + 18, llSubStringIndex(body, "\"}, \"responseDetails\""));
385 }
386
387 //Reverse order if Recepient Language is Hebrew or Arabic
388 if((recepientLanguage == "iw") || (recepientLanguage == "ar"))
389 {
390 tempString = "";
391 for(x = llStringLength(translatedText);x >= 0; x--)
392 {
393 tempString += llGetSubString(translatedText, x, x);
394 }
395 translatedText = tempString;
396 }
397 tempString = speakerName + "(" + languagePair + "): " + translatedText;
398 if(showTranslation)
399 sendIM(speakerID, tempString);
400 for (x = 0; x < llGetListLength(recepientList); x += 1)
401 {
402 recepientID = getAgentKey(llList2Integer(recepientList, x));
403
404 if(recepientID != "")
405 {
406 recepientLanguage = llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [recepientID]) + 1);
407 if(recepientLanguage != speakerLanguage)
408 sendIM(recepientID, tempString);
409 }
410 }
411 return;
412 }
413
414 //===========================
415 //Process Language Detection
416 //===========================
417 if(type == 1)
418 {
419 speakerID = llList2Key(params, 1);
420
421 speakerLanguageReliable = llToLower(llGetSubString(body, llSubStringIndex(body, "\",\"isReliable\":") + 15, llSubStringIndex(body, ",\"confidence\":") - 1)) == "true";
422 speakerLanguageConfidence = (float)llGetSubString(body, llSubStringIndex(body, ",\"confidence\":") + 14, llSubStringIndex(body, "}, \"responseDetails\":") - 1);
423
424 listPos = llListFindList(agentsInTranslation, [speakerID]);
425
426 if(((listPos < 0) && (speakerLanguageReliable) || (speakerLanguageConfidence >= 0.18)))
427 {
428 //Analyze Data
429 tempString = checkLanguage(llToLower(llGetSubString(body, llSubStringIndex(body, "{\"language\":\"") + 13, llSubStringIndex(body, "\",\"isReliable\":") - 1)));
430 if(tempString == "") return;
431
432 if(speakerLanguageConfidence < 0.14)
433 addAgent(speakerID, tempString, TRUE);
434 else
435 addAgent(speakerID, tempString, FALSE);
436 }
437 }
438 }
439
440
441 default
442 {
444 {
445 //Multiplexor Initialization
446 priorityNumber = version*1000000 + llRound(llFrand(499999) + 50000);
447 llListen(broadcastChannel, "", NULL_KEY, "");
448 priorityNumListenID = llListen(priorityNumber, "", NULL_KEY, "");
449
450 //Send out initial heartbeat
451 lastHeartBeat = llGetUnixTime();
452 sendTextBatch(broadcastChannel, llList2CSV([1001, priorityNumber]));
453
454 //Wait for the network to settle down
456 //llSetTimerEvent(10 + ((1-llGetRegionTimeDilation()) * 1));
457 }
458
459 sensor(integer num_detected)
460 {
461 integer x;
462 key id;
463
464 for (x = 0; x < num_detected; x += 1)
465 {
466 id = llDetectedKey(x);
467 if(llListFindList(agentsInTranslation, [id]) < 0)
468 {
469 addNewAgent(id);
470 }
471 }
472 }
473 link_message(integer sender_num, integer num, string str, key id)
474 {
475 integer x;
476 integer listPos;
477 list tempList;
478 integer channelToSpeak;
479
480 //Old Multiplexor
481 if(num == 8434532)
482 {
483 enabled = (integer)str;
484 }
485 else if(num == 3342976)
486 {
487 //Send Preferences
488 options = str;
489 if(isInitialized == FALSE) return;
490 tempList = llCSV2List(options);
491 showTranslation = llList2Integer(tempList, 0);
492 tranObjects = llList2Integer(tempList, 1);
493 autoLanguage = llList2Integer(tempList, 2);
494 sendTextBatch(broadcastChannel, llList2CSV([1004, options]));
495
496 }
497 else if(num == 9384610)
498 {
499 if(isMaster == 0) //markering
500 //llMessageLinked(LINK_THIS, 5598321, llList2CSV([id, str, FALSE]), "");
501 sendTextBatch(broadcastChannel, llList2CSV([1003, id, str, FALSE]));
502 else
503 addAgent(id, str, TRUE);
504 }
505 else if(num == 345149625)
506 {
507 //Return Translation
508 processHTTPResponse(0, str, llCSV2List(id));
509 }
510 else if(num == 345149626)
511 {
512 //Return Detection
513 processHTTPResponse(1, str, llCSV2List(id));
514 }
515 }
516 timer()
517 {
518 integer x;
519 string tempString;
520 list newList;
521 integer translatorCount = llGetListLength(translators)/2;
522
523 if(isInitialized == FALSE)
524 {
525 isInitialized = TRUE;
526 enabled = TRUE;
527 listenID = llListen(0, "", "", "");
528 llListen(777, "", NULL_KEY, "");
529
530 llMessageLinked(LINK_THIS, 6877259, (string)enabled, NULL_KEY);
531 }
532
533 llMessageLinked(LINK_THIS, 94558323, llList2CSV(agentsInTranslation), "");
534 if(isMaster > 0)
535 {
536 for (x = 0; x < llGetListLength(agentsInTranslation); x += 4)
537 {
538 tempString = llList2String(llGetObjectDetails(llList2Key(agentsInTranslation, x), [OBJECT_POS]), 0);
539 if((llVecDist(llGetPos(), (vector)tempString) <= 20.0) && (tempString != ""))
540 newList += llList2List(agentsInTranslation, x, x + 3);
541 }
542
543 agentsInTranslation = newList;
544 if((llGetUnixTime() - lastHeartBeat) >= 5)
545 {
546 //Send heartbeat
547 sendHeartbeat();
548 lastHeartBeat = llGetUnixTime();
549 }
550 }
551 else
552 {
553 if((llGetUnixTime() - lastHeartBeat) >= `0 + llGetListLength(agentsInTranslation)*2 + llPow(translatorCount, 1.4) + translatorCount + ((1-llGetRegionTimeDilation()) * 5))
554 {
555 //Send heartbeat
556 sendHeartbeat();
557 lastHeartBeat = llGetUnixTime();
558 }
559 }
560
561 //turn on and off scanner
562 if((autoLanguage) && (isMaster > 0))
563 {
564 llSensor("", NULL_KEY, AGENT, 20.0, PI);
565 }
567 }
568
569 listen(integer channel, string name, key id, string message)
570 {
571 integer x;
572 string speakerLanguage;
573 string recepientLanguage;
574 integer recepientID;
575 integer listPos;
576 string languagePair;
577 list translationCache;
578 list tempList;
579 integer ImessageType;
580 string Imessage;
581 string tempString;
582 string tempString2;
583
584 //Multiplexor Code
585 if((channel == broadcastChannel) || (channel == priorityNumber))
586 {
587 //==========================
588 //Process Proxy HTTP Request
589 //==========================
590
591 if(channel == priorityNumber)
592 {
593 if(llStringLength(message) >= 508)
594 {
595 if(((integer)message/channel) != 4958654)
596 {
597 sayCachePrivate += [id, message];
598 return;
599 }
600 message = "";
601 }
602 message = receiveTextBatchPrivate(id, message);
603 //Received packet to translate
604 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<0.25, 0.05, 0.25>, "");
605
606 tempList = llParseString2List(message, ["~"], []);
607 tempString = llList2String(tempList, 0);
608 tempList = llDeleteSubList(tempList, 0, 0);
609
610 tempString2 = llDumpList2String(tempList, "|");
611 tempList = llCSV2List(tempString);
612 listPos = llList2Integer(tempList, 0);
613 tempList = llDeleteSubList(tempList, 0, 0);
614
615 checkThrottle(listPos, tempString2, tempList);
616
617 return;
618 }
619
620 //=======================
621 //Process Global Messages
622 //=======================
623 if(llStringLength(message) >= 508)
624 {
625 if(((integer)message/channel) != 4958654)
626 {
627 sayCache += [id, message];
628 return;
629 }
630 message = "";
631 }
632 message = receiveTextBatch(id, message);
633
634 tempList = llCSV2List(message);
635
636 if(llGetListLength(tempList) >= 2)
637 {
638 ImessageType = llList2Integer(tempList, 0);
639 tempList = llDeleteSubList(tempList, 0, 0);
640 Imessage = llList2CSV(tempList);
641
642 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<0.25, 0, 0.25>, "");
643 //Process Message Here
644 if(ImessageType == 1001)
645 {
646 //Incoming Heartbeat
647 if((integer)Imessage == priorityNumber)
648 {
649 llOwnerSay("Priority Number Conflict! Resetting Script...");
650 llResetScript(); //Reset if conflicting priority number
651 }
652 listPos = llListFindList(translators, [id]);
653 if(listPos < 0)
654 {
655 translators += [(integer)Imessage, id];
656 if((isMaster > 0) && (isInitialized))
657 {
658 sendTextBatch((integer)Imessage, llList2CSV([1002, llList2CSV(agentsInTranslation)]));
659 sendTextBatch((integer)Imessage, llList2CSV([1004, options]));
660 }
661 }
662 else
663 {
664 translators = llListReplaceList(translators, [(integer)Imessage], listPos - 1, listPos - 1);
665 }
666 }
667 else if(ImessageType == 1002)
668 {
669 //Incoming agentsInTranslation Master Broadcast
670 if(isMaster == 0)
671 {
672 //llMessageLinked(LINK_THIS, 9458021, Imessage, "");
673 tempList = llCSV2List(Imessage);
674 agentsInTranslation = [];
675 for (x = 0; x < llGetListLength(tempList); x += 4)
676 {
677 agentsInTranslation += [llList2Key(tempList, x), llList2String(tempList, x + 1), llList2Integer(tempList, x + 2), llList2Integer(tempList, x + 3)];
678 }
679 }
680 }
681 else if(ImessageType == 1003)
682 {
683 //Incoming agentsInTranslation dump from Slave
684 tempList = llCSV2List(Imessage);
685 for (x = 0; x < llGetListLength(tempList); x += 4)
686 {
687 addAgent(llList2Key(tempList, x), llList2String(tempList, x + 1), llList2Integer(tempList, x + 2));
688 }
689 }
690 else if(ImessageType == 1004)
691 {
692 //Incoming Preferences
693 options = Imessage;
694 tempList = llCSV2List(options);
695 showTranslation = llList2Integer(tempList, 0);
696 tranObjects = llList2Integer(tempList, 1);
697 autoLanguage = llList2Integer(tempList, 2);
698
699 llMessageLinked(LINK_THIS, 3342977, Imessage, "");
700 }
701 }
702
703 return;
704 }
705
706 //Translator Engine Code
707 if((llToLower(message) == "translator") && (isMaster > 0))
708 {
709 llMessageLinked(LINK_THIS, 2540664, message, id);
710 return;
711 }
712 if((!enabled) && (isMaster == 1)) return;
713
714 if(!tranObjects)
715 {
717 }
718
719 listPos = llListFindList(agentsInTranslation, [id]);
720 if(listPos >= 0)
721 {
722 speakerLanguage = llList2String(agentsInTranslation, listPos + 1);
723 }
724 else
725 {
726 speakerLanguage = addNewAgent(id);
727 }
728
729 if(speakerLanguage == "xx") return; //Agent Opt-Out
730
731 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<1, 1, 0>, "");
732 //===============================
733 //Formulate Translation Requests
734 //===============================
735 for (x = 0; x < llGetListLength(agentsInTranslation); x += 4)
736 {
737 //Loop through translation group and do appropriate translations as needed
738 recepientID = llList2Integer(agentsInTranslation, x + 3);
739 recepientLanguage = checkLanguage(llList2Key(agentsInTranslation, x + 1));
740 if((speakerLanguage != recepientLanguage) && (recepientLanguage != "") && (recepientLanguage != "xx"))
741 {
742 languagePair = speakerLanguage + "|" + recepientLanguage;
743
744 listPos = llListFindList(translationCache, [languagePair]);
745 if(listPos < 0)
746 translationCache += [languagePair, recepientID];
747 else
748 translationCache = llListReplaceList(translationCache, [llList2String(translationCache, listPos + 1) + "@" + (string)recepientID], listPos + 1, listPos + 1);
749 }
750 }
751
752 //Process Requests
753 if(llGetListLength(translationCache) > 0)
754 {
755 for (x = 0; x < llGetListLength(translationCache); x += 2)
756 {
757 //====================================
758 //Translation
759 //====================================
760 //Forumulate and Send Translation Request
761 languagePair = "|" + llList2String(llParseStringKeepNulls(llList2String(translationCache, x), ["|"],[]), 1);
762 checkThrottle(0, llEscapeURL(message) + "&langpair=" + llEscapeURL(languagePair), [llGetTime(), id , llList2String(translationCache, x + 1), llList2String(translationCache, x)]);
763 }
764 }
765 else
766 speakerLanguage = "";
767
768 //====================================
769 //Language Detection
770 //====================================
772 {
773 if(((speakerLanguage == "") || (llList2Integer(agentsInTranslation, llListFindList(agentsInTranslation, [id]) + 2) == TRUE)) || (isMaster == 2))
774 {
775 //Forumulate and Send Language Detect Request
776 checkThrottle(1, llEscapeURL(message), [llGetTime(), id]);
777 }
778 }
779 }
780
781 http_response(key request_id, integer status, list metadata, string body)
782 {
783 string tempString;
784
785 if(status != 200)
786 {
787 //llOwnerSay("WWW Error:" + (string)status);
788 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<1, 0, 0>, "");
789 //llOwnerSay(body);
790 return;
791 }
792
793 //Process Resonse Code
794 tempString = llGetSubString(body, llSubStringIndex(body, "\"responseStatus\":"), -1);
795 status = (integer)llGetSubString(tempString, 17, llSubStringIndex(tempString, "}") - 1);
796 if(status != 200)
797 {
798 //llOwnerSay("Language Server Returned Error Code: " + (string)status);
799 //llOwnerSay(body);
800 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<1, 0, 0>, "");
801 return;
802 }
803 llMessageLinked(LINK_ALL_CHILDREN, 6634934, (string)<0, 0, 1>, "");
804 llMessageLinked(LINK_THIS, 345149624, body, request_id);
805 }
806 }
807

Universal_Google_Translator

HTTP Handler

Even though the name of this script is "HTTP Handler", it really just stores the requested translation traffic so that we can match incoming translations from Google with what was requested. Since this takes a lot of memory for storage, this information is kept out of the engine script. When an incoming HTTP response comes in, we fetch the data from here. If the requests didn't come back in a timely fashion, we remove it from the queue.

Category: Translator
By : Hank Ramos
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 //HTTP Handler
2 //Copyright 2006-2009 by Hank Ramos
3
4 list requestedTranslations;
5 list requestedDetections;
6
7 default
8 {
10 {
12 }
13
14 timer()
15 {
16 integer x;
17 list newList;
18 float timeElapsed;
19
20 for (x = 0; x < llGetListLength(requestedDetections); x += 2)
21 {
22 timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedDetections, x + 1)), 0);
23 if(timeElapsed < 60.0)
24 newList += llList2List(requestedDetections, x, x + 1);
25 }
26 requestedDetections = newList;
27 newList = [];
28 for (x = 0; x < llGetListLength(requestedTranslations); x += 2)
29 {
30 timeElapsed = llGetTime() - llList2Float(llCSV2List(llList2String(requestedTranslations, x + 1)), 0);
31 if(timeElapsed < 60.0)
32 {
33 newList += llList2List(requestedTranslations, x, x + 1);
34 }
35 }
36 requestedTranslations = newList;
37 }
38
39 link_message(integer sender_num, integer num, string str, key id)
40 {
41 integer listPos;
42
43 if(num == 235365342)
44 {
45 //Translation
46 requestedTranslations += [id, str];
47 }
48 else if(num == 235365343)
49 {
50 //Detection
51 requestedDetections += [id, str];
52 }
53 else if(num == 345149624)
54 {
55 listPos = llListFindList(requestedTranslations, [id]);
56 if(listPos >= 0)
57 {
58 llMessageLinked(LINK_THIS, 345149625, str, llList2String(requestedTranslations, listPos + 1));
59 requestedTranslations = llDeleteSubList(requestedTranslations, listPos, listPos + 1);
60 return;
61 }
62
63 listPos = llListFindList(requestedDetections, [id]);
64 if(listPos >= 0)
65 {
66 llMessageLinked(LINK_THIS, 345149626, str, llList2String(requestedDetections, listPos + 1));
67 requestedDetections = llDeleteSubList(requestedDetections, listPos, listPos + 1);
68 }
69 }
70 }
71 }

Universal_Google_Translator

Interface Handler

This is the interface, or menu-system of the translator. It handles all of the numerous dialogs, language selection, etc. of the translator.

Category: Translator
By : Hank Ramos
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 //Menu System
2 //Copyright 2006-2009 by Hank Ramos
3
4 //Variables
5 integer randomDialogChannel;
6 integer lastAttachPoint;
7 list detectedAgentKeyList;
8 list detectedAgentNameList;
9 key agentInDialog;
10 integer isInitialized = FALSE;
11 list agentsInTranslation;
12 integer translatorCount;
13
14 //Options
15 integer groupAccess = FALSE;
16 integer autoLanguage = TRUE;
17 integer deviceAttached;
18 integer enabled = FALSE;
19 integer isShowTran = FALSE;
20 integer showAgents = TRUE;
21 string displayStringMD5;
22 integer isMaster = 1;
23 integer tranObjects = TRUE;
24
25 //Constants
26 list languages= [
27 "Chinese-Simple", "Chinese-Trad", "Croatian",
28 "Bulgarian", "Belarusian", "Catlan",
29 "Afrikaans", "Albanian", "Arabic",
30
31 "Filipino", "French", "Galician",
32 "Finnish", "English", "Estonian",
33 "Czech", "Danish", "Dutch",
34
35 "Indonesian", "Irish", "Italian",
36 "Hindi", "Hungarian", "Icelandic",
37 "German", "Greek", "Hebrew",
38
39 "Maltese", "Norwegian", "Persian",
40 "Lithuanian", "Macedonian", "Malay",
41 "Japanese", "Korean", "Latvian",
42
43 "Slovenian", "Spanish", "Swahili",
44 "Russian", "Serbian", "Slovak",
45 "Polish", "Portuguese", "Romanian",
46
47 "Yiddish", "\t ", "\t ",
48 "Ukrainian", "Vietnamese", "Welsh",
49 "Swedish", "Thai", "Turkish"];
50
51 list languageCodes = [
52 "zh-CN", "zh-TW", "hr",
53 "bg", "be", "ca",
54 "af", "sq", "ar",
55
56 "tl", "fr", "gl",
57 "fi", "en", "et",
58 "cs", "da", "nl",
59
60 "id", "ga", "it",
61 "hi", "hu", "is",
62 "de", "el", "iw",
63
64 "mt", "no", "fa",
65 "lt", "mk", "ms",
66 "ja", "ko", "lv",
67
68 "sl", "es", "sw",
69 "ru", "sr", "sk",
70 "pl", "pt-PT", "ro",
71
72 "yi", "", "",
73 "uk", "vi", "cy",
74 "sv", "th", "tr"];
75
76 //Functions
77 //Takes in the offsets, and the attach point
78 vector fn_makePos(integer attach_point, vector offset) {
79 if((attach_point == 31) || (attach_point == 35)) { //center 2 & center
80 return <0,0,0>;
81 } else if(attach_point == 32) { // Top right
82 return <offset.x, offset.y, offset.z * -1>;
83 } else if(attach_point == 33) { // Top
84 return <offset.x, 0, offset.z * -1>;
85 } else if(attach_point == 34) { // Top Left
86 return <offset.x, offset.y * -1, offset.z * -1>;
87 } else if(attach_point == 36) { // Bottom Left
88 return <offset.x, offset.y * -1 , offset.z>;
89 } else if(attach_point == 37) { // Bottom
90 return <offset.x, 0, offset.z>;
91 } else if(attach_point == 38) { // Bottom Right - Baseline
92 return offset;
93 } else { //Not a HUD point? Then return it's current pos
94 return llGetLocalPos();
95 }
96 }
97
98 updateDisplay()
99 {
100 string tempString;
101 integer listLength;
102 integer x;
103 string agentName;
104
105 if(isInitialized == FALSE) return;
106 tempString = "Universal Translator";
107 if(isMaster != 1)
108 tempString += " (Link-" + (string)(translatorCount + 1) + ")";
109 tempString += "\n===============";
110
111 if(enabled)
112 {
113 listLength = llGetListLength(agentsInTranslation);
114 if(((showAgents) && (listLength <= 40)) && (listLength != 0))
115 {
116 for (x = 0; x < listLength; x += 4)
117 {
118 agentName = llList2String(llGetObjectDetails(llList2Key(agentsInTranslation, x), [OBJECT_NAME]), 0);
119 if(llStringLength(agentName) > 25)
120 agentName = llGetSubString(agentName, 0, 24);
121 if(agentName != "")
122 tempString += "\n" + agentName + "(" + llList2String(agentsInTranslation, x + 1) + ")";
123 }
124 }
125 else
126 {
127 tempString += "\n# Agents Translated: " + (string)llRound(listLength/3);
128 }
129 }
130 else
131 {
132 tempString += "\n>> Disabled <<";
133 }
134
135 if(llMD5String(tempString, 0) != displayStringMD5)
136 {
137 displayStringMD5 = llMD5String(tempString, 0);
138 llSetText(tempString, <1,1,1>, 1);
139 }
140 }
141
142 showMainMenu(key id)
143 {
144 if(isInitialized == FALSE) return;
145 integer avatarParticipating;
146 list buttonList = ["Language", "Help"];
147 string dialogMsg = "Main Menu\nLANGUAGE: manually choose your source language. Target languages are detected automatically\nHELP: get help notecard";
148 buttonList += "FREE Copy";
149 dialogMsg += "\nFREE COPY: receive FREE copy of Universal Translator.";
150
151 if(llList2String(agentsInTranslation, llListFindList(agentsInTranslation, [(string)id]) + 1) != "xx")
152 {
153 buttonList += "Opt-Out";
154 dialogMsg += "\nOPT-OUT: disable receipt of translations";
155 }
156 else
157 {
158 buttonList += "Opt-In";
159 dialogMsg += "\nOPT-IN: join the translations";
160 }
161
162 if(id == llGetOwner())
163 {
164 buttonList += "Donate";
165 dialogMsg += "\nDONATE: donate L$ to the developer of Universal Translator.";
166 }
167 if((id == llGetOwner()) || ((groupAccess) && (llSameGroup(id))))
168 {
169 buttonList += "Reset";
170 buttonList += "Options";
171 buttonList += "Send Copy";
172 dialogMsg += "\nSEND COPY: send FREE copy of Universal Translator.";
173
174 if(enabled)
175 {
176 buttonList += "Disable";
177 }
178 else
179 {
180 buttonList += "Enable";
181 }
182
183 dialogMsg += "\nRESET: reset all scripts in translator";
184 }
185
186 llDialog(id, dialogMsg, buttonList, randomDialogChannel);
187 }
188
189 showOptionsMenu(key id)
190 {
191 integer avatarParticipating;
192 list buttonList = [];
193 string dialogMsg = "Options Menu.";
194 if(id == llGetOwner())
195 {
196 if(groupAccess)
197 {
198 buttonList += "Group OFF";
199 }
200 else
201 {
202 buttonList += "Group ON";
203 }
204 dialogMsg += "\nGROUP: allow group members to admin.";
205 }
206 if((id == llGetOwner()) || ((groupAccess) && (llSameGroup(id))))
207 {
208 buttonList += "Main Menu";
209 if(!deviceAttached)
210 {
211 if(autoLanguage)
212 {
213 buttonList += "Scan OFF";
214 }
215 else
216 {
217 buttonList += "Scan ON";
218 }
219 }
220 dialogMsg += "\nSCAN: scan for Avatars and automatically add to translation matrix.";
221
222 if(isShowTran)
223 {
224 buttonList += "Echo OFF";
225 }
226 else
227 {
228 buttonList += "Echo ON";
229 }
230 dialogMsg += "\nECHO: show translations of your chat sent to others.";
231
232
233 if(tranObjects)
234 {
235 buttonList += "Objects OFF";
236 }
237 else
238 {
239 buttonList += "Objects ON";
240 }
241 dialogMsg += "\nOBJECTS: translate chat of scripted objects";
242
243 if(showAgents)
244 {
245 buttonList += "Agents OFF";
246 }
247 else
248 {
249 buttonList += "Agents ON";
250 }
251 dialogMsg += "\AGENTS: show list of agents translated.";
252 }
253
254 llDialog(id, dialogMsg, buttonList, randomDialogChannel);
255 }
256
257 showLanguageDialog1(key id)
258 {
259 llDialog(id, "Select your TARGET language...", ["\t", "\t", ">> NEXT"] + llList2List(languages, 0, 8), randomDialogChannel);
260 }
261 showLanguageDialog2(key id)
262 {
263 llDialog(id, "Select your TARGET language..", ["<< BACK", "\t ", ">> NEXT "] + llList2List(languages, 9, 17), randomDialogChannel);
264 }
265 showLanguageDialog3(key id)
266 {
267 llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 18, 26), randomDialogChannel);
268 }
269 showLanguageDialog4(key id)
270 {
271 llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 27, 35), randomDialogChannel);
272 }
273 showLanguageDialog5(key id)
274 {
275 llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", ">> NEXT "] + llList2List(languages, 36, 44), randomDialogChannel);
276 }showLanguageDialog6(key id)
277 {
278 llDialog(id, "Select your TARGET language..", ["<< BACK ", "\t ", "\t "] + llList2List(languages, 45, 53), randomDialogChannel);
279 }
280 processListen(string name, key id, string message)
281 {
282 key listenKey;
283
284 if(llListFindList(languages, [message]) > -1) //Language Selected in Dialog
285 {
286 if(message != "") llMessageLinked(LINK_THIS, 9384610, llList2String(languageCodes, llListFindList(languages, [message])), id);
287 }
288 else if(llToLower(message) == "help")
289 {
290 llGiveInventory(id, "Universal Translator Help");
291 }
292 else if(message == "Main Menu")
293 {
294 showMainMenu(id);
295 }
296 else if(message == "Options")
297 {
298 showOptionsMenu(id);
299 }
300 else if(message == "Language")
301 {
302 showLanguageDialog1(id);
303 }
304 else if(message == "Opt-In")
305 {
306 showLanguageDialog1(id);
307 }
308 else if(message == "Opt-Out")
309 {
310 llMessageLinked(LINK_THIS, 9384610, "xx", id);
311 }
312 else if(message == "FREE Copy")
313 {
314 llMessageLinked(LINK_THIS, 9455209, llKey2Name(id), id);
315 }
316 if(id == llGetOwner())
317 {
318 if(message == "Group ON")
319 {
320 groupAccess = TRUE;
321 showMainMenu(id);
322 }
323 else if(message == "Group OFF")
324 {
325 groupAccess = FALSE;
326 showMainMenu(id);
327 }
328 else if(message == "Donate")
329 {
330 llMessageLinked(LINK_THIS, 324235353254, "", llGetOwner());
331 }
332 }
333 if((id == llGetOwner()) || ((groupAccess) && (llSameGroup(id))))
334 {
335 if(message == "Reset")
336 {
338 }
339 else if(message == "Enable")
340 {
341 enabled = TRUE;
342 llMessageLinked(LINK_THIS, 8434532, (string)enabled, id);
343 }
344 else if(message == "Disable")
345 {
346 enabled = FALSE;
347 llMessageLinked(LINK_THIS, 8434532, (string)enabled, id);
348 }
349 else if(message == "Echo ON")
350 {
351 isShowTran = TRUE;
352 //llMessageLinked(LINK_THIS, 2734322, (string)isShowTran, id);
353 }
354 else if(message == "Echo OFF")
355 {
356 isShowTran = FALSE;
357 }
358 else if(message == "Objects OFF")
359 {
360 tranObjects = FALSE;
361 }
362 else if(message == "Objects ON")
363 {
364 tranObjects = TRUE;
365 }
366 else if(message == "Agents OFF")
367 {
368 showAgents = FALSE;
369 llMessageLinked(LINK_THIS, 455832, (string)showAgents, id);
370 }
371 else if(message == "Agents ON")
372 {
373 showAgents = TRUE;
374 llMessageLinked(LINK_THIS, 455832, (string)showAgents, id);
375 }
376 else if(message == "Scan ON")
377 {
378 autoLanguage = TRUE;
379 showMainMenu(id);
380 }
381 else if(message == "Scan OFF")
382 {
383 autoLanguage = FALSE;
384 showMainMenu(id);
385 }
386 else if((message == "Send Copy") || (message == ">>RESCAN<<"))
387 {
388 agentInDialog = id;
389 llSensor("", NULL_KEY, AGENT, 20.0, TWO_PI);
390 }
391 else
392 {
393 if(llGetListLength(detectedAgentNameList) > 0)
394 {
395 listenKey = llList2Key(detectedAgentKeyList, llListFindList(detectedAgentNameList, [message]));
396 if(listenKey != "")
397 {
398 llMessageLinked(LINK_THIS, 9455209, message, listenKey);
399 }
400 detectedAgentNameList = [];
401 }
402 }
403 }
404 if(message == ">> NEXT")
405 {
406 showLanguageDialog2(id);
407 }
408 else if(message == ">> NEXT ")
409 {
410 showLanguageDialog3(id);
411 }
412 else if(message == ">> NEXT ")
413 {
414 showLanguageDialog4(id);
415 }
416 else if(message == ">> NEXT ")
417 {
418 showLanguageDialog5(id);
419 }
420 else if(message == ">> NEXT ")
421 {
422 showLanguageDialog6(id);
423 }
424 else if(message == "<< BACK")
425 {
426 showLanguageDialog1(id);
427 }
428 else if(message == "<< BACK ")
429 {
430 showLanguageDialog2(id);
431 }
432 else if(message == "<< BACK ")
433 {
434 showLanguageDialog3(id);
435 }
436 else if(message == "<< BACK ")
437 {
438 showLanguageDialog4(id);
439 }
440 else if(message == "<< BACK ")
441 {
442 showLanguageDialog5(id);
443 }
444 if(message == "\t")
445 {
446 showLanguageDialog1(id);
447 }
448 else if(message == "\t ")
449 {
450 showLanguageDialog2(id);
451 }
452 else if(message == "\t ")
453 {
454 showLanguageDialog3(id);
455 }
456 else if(message == "\t ")
457 {
458 showLanguageDialog4(id);
459 }
460 else if(message == "\t ")
461 {
462 showLanguageDialog5(id);
463 }
464 else if(message == "\t ")
465 {
466 showLanguageDialog6(id);
467 }
468
469 llMessageLinked(LINK_THIS, 3342976, llList2CSV([isShowTran, tranObjects, autoLanguage]), id);
470 }
471 checkAttach()
472 {
473 if(llGetAttached() > 0)
474 {
475 llSetScale(<0.125, 0.125, 0.087>);
476 if(lastAttachPoint != llGetAttached())
477 {
478 llSetPos(fn_makePos(llGetAttached(), <0.00000, 0.13500, 0.15433>));
479 llSetRot(<0,0,0,1>);
480 lastAttachPoint = llGetAttached();
481 }
484 }
485 else
486 {
487 llSetScale(<0.5, 0.5, 0.750>);
490 }
491 }
492
493 default
494 {
496 {
497 //integer hasPerms = llGetPermissions();
499 }
501 {
503
504 string speakerLanguage;
505 //llOwnerSay("Welcome to the Universal Translator, the best FREE translator in SL! Please consider making a L$ donation to help with maintenance and further updates. Select DONATE in the translator menu to make a donation.");
506 //llSetText("Initializing...", <1,1,1>, 1);
507
508 llSetText("Searching for\nnearby translators...", <1,1,1>, 1);
509 checkAttach();
510
511 randomDialogChannel = -(integer)llFrand(2147483647);
512
513 llMessageLinked(LINK_SET, 20957454, "", NULL_KEY);
514 llResetOtherScript("Universal Translator Engine");
515 llResetOtherScript("HTTP Handler");
516 llResetOtherScript("No-Script IM Handler");
517 llResetOtherScript("Auto-Update");
518 llResetOtherScript("Donation");
519
520 //Other Setup
521 llSleep(5);
522 llListen(randomDialogChannel, "", NULL_KEY, "");
523 llMessageLinked(LINK_THIS, 3342976, llList2CSV([isShowTran, tranObjects, autoLanguage]), "");
524
525 //llOwnerSay("Mem Free=" + (string)llGetFreeMemory());
526 }
527
528 on_rez(integer startup_param)
529 {
530 //checkAttach();
532 }
533
534 sensor(integer num_detected)
535 {
536 integer x;
537 string tempString;
538
539 if(num_detected > 11)
540 num_detected = 11;
541
542 detectedAgentKeyList = [];
543 detectedAgentNameList = [];
544 for (x = 0; x < num_detected; x += 1)
545 {
546 detectedAgentKeyList += llDetectedKey(x);
547 tempString = llDetectedName(x);
548 if(llStringLength(tempString) > 24) tempString = llGetSubString(tempString, 0, 23);
549 detectedAgentNameList += tempString;
550 }
551 if(llGetListLength(detectedAgentNameList) > 0)
552 {
553 llDialog(agentInDialog, "Select someone nearby to receive FREE a copy of the Universal Translator...", [">>RESCAN<<"] + detectedAgentNameList, randomDialogChannel);
554 }
555 }
556 link_message(integer sender_num, integer num, string str, key id)
557 {
558 integer listPos;
559 list tempList;
560 string tempString;
561
562 if(num == 2540664)
563 {
564 showMainMenu(id);
565 }
566 else if(num == 3792114)
567 {
568 deviceAttached = (integer)str;
569 if(deviceAttached) autoLanguage = TRUE;
570 }
571 else if(num == 65635544)
572 {
573 translatorCount = ((integer)str)/2;
574 }
575 else if(num == 6877259)
576 {
577 if(isInitialized == FALSE)
578 {
579 isInitialized = TRUE;
580 //Owner Language Detection
581 tempString = llGetAgentLanguage(llGetOwner());
582 if(llGetSubString(tempString, 0, 1) == "en") tempString = "en";
583
584 if(tempString == "")
585 {
586 tempString = "en";
587 }
588 llMessageLinked(LINK_THIS, 9384610, tempString, llGetOwner());
589 }
590
591 enabled = (integer)str; //marker
592 updateDisplay();
593 }
594 else if(num == 34829304)
595 {
596 isMaster = (integer)str;
597 updateDisplay();
598 }
599 else if(num == 455832)
600 {
601 showAgents = (integer)str;
602 updateDisplay();
603 }
604 else if(num == 94558323)
605 {
606 agentsInTranslation = llCSV2List(str);
607 updateDisplay();
608 }
609 else if(num == 3342977)
610 {
611 //Options are Show Tran and tranObjects at this time
612 tempList = llCSV2List(str);
613 isShowTran = llList2Integer(tempList, 0);
614 tranObjects = llList2Integer(tempList, 1);
615 autoLanguage = llList2Integer(tempList, 2);
616 }
617 else if(num == 32364364)
618 {
619 //Send Options
620 llMessageLinked(LINK_THIS, 8434532, (string)enabled, NULL_KEY);
621 }
622 }
623
624 touch_start(integer num_detected)
625 {
626 integer x;
627 key avatarKey;
628
629 for (x = 0; x < num_detected; x++)
630 {
631 avatarKey = llDetectedKey(x);
632 showMainMenu(avatarKey);
633 }
634 }
635
636 listen(integer channel, string name, key id, string message)
637 {
638 processListen(name, id, message);
639 }
640
641 attach(key id)
642 {
643 checkAttach();
644 if(id) //tests if it is a valid key and not NULL_KEY
645 {
647 }
648 }
649 control(key id,integer held, integer change) {
650 return;
651 }
652 }
653

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