sloodle_mod_glossary-1.0.lslp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. // "PictureGloss" -- SLOODLE MetaGloss modified to show textures instead of text definitions
  4. ///////////////////////////////////////////
  5. // Allows users in-world to search the Moodle glossary
  6. // for images and displays them while resizing the prim.
  7. // Part of the Sloodle project (www.sloodle.org)
  8. //
  9. // Copyright (c) 2006-9 SLOODLE (various contributors)
  10. // Released under the GNU GPL
  11. //
  12. // Contributors:
  13. // Jeremy Kemp
  14. // Peter R. Bloomfield
  15. //
  16. ///////////////////////////////////////////
  17. integer SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST=-1828374651; // this channel is used to send status codes for translation to the error_messages lsl script
  18. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;
  19. integer SLOODLE_CHANNEL_AVATAR_DIALOG;
  20. string SLOODLE_GLOSSARY_LINKER = "/mod/sloodle/mod/glossary-1.0/linker.php";
  21. string SLOODLE_EOF = "sloodleeof";
  22. integer MENU_CHANNEL;
  23. string SLOODLE_OBJECT_TYPE = "glossary-1.0"; // We just use the regular glossary tools server-side
  24. integer SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC = 0;
  25. integer SLOODLE_OBJECT_ACCESS_LEVEL_OWNER = 1;
  26. integer SLOODLE_OBJECT_ACCESS_LEVEL_GROUP = 2;
  27. integer objChat=1;
  28. integer ON =1;
  29. integer OFF = 2;
  30. integer sloodleobjectaccesslevelctrl = 0; // Who can control this object?
  31. string sloodleserverroot = "";
  32. string sloodlepwd = "";
  33. integer sloodlecontrollerid = 0;
  34. integer sloodlemoduleid = 0;
  35. integer sloodleobjectaccessleveluse = 0; // Who can use this object?
  36. integer sloodleserveraccesslevel = 0; // Who can use the server resource? (Value passed straight back to Moodle)
  37. integer sloodlepartialmatches = 1;
  38. integer sloodlesearchaliases = 0;
  39. integer sloodlesearchdefinitions = 0;
  40. integer sloodleidletimeout = 120; // How many seconds before automatic idle timeout? (0 means don't timeout)
  41. string sloodleglossaryname = ""; // Name of the glossary
  42. integer isconfigured = FALSE; // Do we have all the configuration data we need?
  43. integer eof = FALSE; // Have we reached the end of the configuration data?
  44. key httpcheck = NULL_KEY; // Request used to check the glossary
  45. key httpsearch = NULL_KEY; // Request used to search the glossary
  46. float HTTP_TIMEOUT = 10.0; // Period of time to wait for an HTTP response before giving up
  47. string SLOODLE_METAGLOSS_COMMAND = "/pix "; // The command prefix for searching via chat message
  48. string searchterm = ""; // The term to be searched
  49. key searcheruuid = NULL_KEY; // Key of the avatar searching
  50. string PICTUREGLOSS_TEXTURE = "SLOODLE PictureGloss texture"; // Name of the default texture to display on the PictureGloss
  51. ///// TRANSLATION /////
  52. // Link message channels
  53. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
  54. integer SLOODLE_CHANNEL_TRANSLATION_RESPONSE = -1928374652;
  55. // Translation output methods
  56. string SLOODLE_TRANSLATE_LINK = "link"; // No output parameters - simply returns the translation on SLOODLE_TRANSLATION_RESPONSE link message channel
  57. string SLOODLE_TRANSLATE_SAY = "say"; // 1 output parameter: chat channel number
  58. string SLOODLE_TRANSLATE_WHISPER = "whisper"; // 1 output parameter: chat channel number
  59. string SLOODLE_TRANSLATE_SHOUT = "shout"; // 1 output parameter: chat channel number
  60. string SLOODLE_TRANSLATE_REGION_SAY = "regionsay"; // 1 output parameter: chat channel number
  61. string SLOODLE_TRANSLATE_OWNER_SAY = "ownersay"; // No output parameters
  62. string SLOODLE_TRANSLATE_DIALOG = "dialog"; // Recipient avatar should be identified in link message keyval. At least 2 output parameters: first the channel number for the dialog, and then 1 to 12 button label strings.
  63. string SLOODLE_TRANSLATE_LOAD_URL = "loadurl"; // Recipient avatar should be identified in link message keyval. 1 output parameter giving URL to load.
  64. string SLOODLE_TRANSLATE_HOVER_TEXT = "hovertext"; // 2 output parameters: colour <r,g,b>, and alpha value
  65. string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
  66. // Send a translation request link message
  67. sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch)
  68. {
  69. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
  70. }
  71. ///// ----------- /////
  72. ///// FUNCTIONS /////
  73. /******************************************************************************************************************************
  74. * sloodle_error_code -
  75. * Author: Paul Preibisch
  76. * Description - This function sends a linked message on the SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST channel
  77. * The error_messages script hears this, translates the status code and sends an instant message to the avuuid
  78. * Params: avuuid - this is the avatar UUID to that an instant message with the translated error code will be sent to
  79. * Params: status code - the status code of the error as on our wiki: http://slisweb.sjsu.edu/sl/index.php/Sloodle_status_codes
  80. *******************************************************************************************************************************/
  81. sloodle_error_code(string method, key avuuid,integer statuscode){
  82. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST, method+"|"+(string)avuuid+"|"+(string)statuscode, NULL_KEY);
  83. }
  84. sloodle_debug(string msg)
  85. {
  86. llMessageLinked(LINK_THIS, DEBUG_CHANNEL, msg, NULL_KEY);
  87. }
  88. sloodle_reset()
  89. {
  90. sloodle_translation_request(SLOODLE_TRANSLATE_IM, [llGetOwner()], "resetting", [], NULL_KEY, "");
  91. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reset", NULL_KEY);
  92. llResetScript();
  93. }
  94. // Configure by receiving a linked message from another script in the object
  95. // Returns TRUE if the object has all the data it needs
  96. integer sloodle_handle_command(string str)
  97. {
  98. list bits = llParseString2List(str,["|"],[]);
  99. integer numbits = llGetListLength(bits);
  100. string name = llList2String(bits,0);
  101. string value1 = "";
  102. string value2 = "";
  103. if (numbits > 1) value1 = llList2String(bits,1);
  104. if (numbits > 2) value2 = llList2String(bits,2);
  105. if (name == "set:sloodleserverroot") sloodleserverroot = value1;
  106. else if (name == "set:sloodlepwd") {
  107. // The password may be a single prim password, or a UUID and a password
  108. if (value2 != "") sloodlepwd = value1 + "|" + value2;
  109. else sloodlepwd = value1;
  110. } else if (name == "set:sloodlecontrollerid") sloodlecontrollerid = (integer)value1;
  111. else if (name == "set:sloodlemoduleid") sloodlemoduleid = (integer)value1;
  112. else if (name == "set:sloodleobjectaccessleveluse") sloodleobjectaccessleveluse = (integer)value1;
  113. else if (name == "set:sloodleserveraccesslevel") sloodleserveraccesslevel = (integer)value1;
  114. else if (name == "set:sloodlepartialmatches") sloodlepartialmatches = (integer)value1;
  115. else if (name == "set:sloodlesearchaliases") sloodlesearchaliases = (integer)value1;
  116. else if (name == "set:sloodlesearchdefinitions") sloodlesearchdefinitions = (integer)value1;
  117. else if (name == "set:sloodleidletimeout") sloodleidletimeout = (integer)value1;
  118. else if (name == SLOODLE_EOF) eof = TRUE;
  119. return (sloodleserverroot != "" && sloodlepwd != "" && sloodlecontrollerid > 0 && sloodlemoduleid > 0);
  120. }
  121. // Checks if the given agent is permitted to control this object
  122. // Returns TRUE if so, or FALSE if not
  123. integer sloodle_check_access_ctrl(key id)
  124. {
  125. // Check the access mode
  126. if (sloodleobjectaccesslevelctrl == SLOODLE_OBJECT_ACCESS_LEVEL_GROUP) {
  127. return llSameGroup(id);
  128. } else if (sloodleobjectaccesslevelctrl == SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC) {
  129. return TRUE;
  130. }
  131. // Assume it's owner mode
  132. return (id == llGetOwner());
  133. }
  134. // Checks if the given agent is permitted to user this object
  135. // Returns TRUE if so, or FALSE if not
  136. integer sloodle_check_access_use(key id)
  137. {
  138. // Check the access mode
  139. if (sloodleobjectaccessleveluse == SLOODLE_OBJECT_ACCESS_LEVEL_GROUP) {
  140. return llSameGroup(id);
  141. } else if (sloodleobjectaccessleveluse == SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC) {
  142. return TRUE;
  143. }
  144. // Assume it's owner mode
  145. return (id == llGetOwner());
  146. }
  147. ///// STATES /////
  148. // Default state - waiting for configuration
  149. default
  150. {
  151. state_entry()
  152. {
  153. SLOODLE_CHANNEL_AVATAR_DIALOG = 6000000 + (integer)(llFrand( 6000001 )); //create a random channel to listen on so that your object doesnt cause another objects menu to appear!
  154. llListen(MENU_CHANNEL,"",llGetOwner(),"");
  155. llListen(MENU_CHANNEL,"",llGetOwner(),"");
  156. // Starting again with a new configuration
  157. isconfigured = FALSE;
  158. eof = FALSE;
  159. // Reset our data
  160. sloodleserverroot = "";
  161. sloodlepwd = "";
  162. sloodlecontrollerid = 0;
  163. sloodlemoduleid = 0;
  164. sloodleobjectaccessleveluse = 0;
  165. sloodleserveraccesslevel = 0;
  166. sloodlepartialmatches = 1;
  167. sloodlesearchaliases = 0;
  168. sloodlesearchdefinitions = 0;
  169. sloodleidletimeout = 120;
  170. sloodleglossaryname = "";
  171. // Reset to our default texture and size
  172. llSetScale(<1.0, 1.0, 1.0>);
  173. llSetTexture(PICTUREGLOSS_TEXTURE, ALL_SIDES);
  174. }
  175. link_message( integer sender_num, integer num, string str, key id)
  176. {
  177. // Check the channel
  178. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  179. // Split the message into lines
  180. list lines = llParseString2List(str, ["\n"], []);
  181. integer numlines = llGetListLength(lines);
  182. integer i = 0;
  183. for (; i < numlines; i++) {
  184. isconfigured = sloodle_handle_command(llList2String(lines, i));
  185. }
  186. // If we've got all our data AND reached the end of the configuration data, then move on
  187. if (eof == TRUE) {
  188. if (isconfigured == TRUE) {
  189. sloodle_translation_request(SLOODLE_TRANSLATE_IM, [llGetOwner()], "configurationreceived", [], NULL_KEY, "");
  190. state check_glossary;
  191. } else {
  192. // Go all configuration but, it's not complete... request reconfiguration
  193. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [llGetOwner()], "configdatamissing", [], NULL_KEY, "");
  194. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
  195. eof = FALSE;
  196. }
  197. }
  198. }
  199. }
  200. touch_start(integer num_detected)
  201. {
  202. key id = llDetectedKey(0);
  203. // Determine what this user can do
  204. // Attempt to request a reconfiguration
  205. if (llDetectedKey(0) == llGetOwner()) {
  206. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:requestconfig", NULL_KEY);
  207. }
  208. }
  209. }
  210. // If necessary, check the name of the glossary
  211. state check_glossary
  212. {
  213. on_rez(integer par)
  214. {
  215. state default;
  216. }
  217. link_message( integer sender_num, integer num, string str, key id)
  218. {
  219. // Check the channel
  220. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  221. // Is it a reset message?
  222. if (str == "do:reset") llResetScript();
  223. }
  224. }
  225. state_entry()
  226. {
  227. // Lookup the glossary name
  228. sloodleglossaryname = "";
  229. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0,1.0,0.0>, 0.8], "picturegloss:checking", [], NULL_KEY, "picturegloss");
  230. httpcheck = llHTTPRequest(sloodleserverroot + SLOODLE_GLOSSARY_LINKER + "?sloodlecontrollerid=" + (string)sloodlecontrollerid + "&sloodlepwd=" + sloodlepwd + "&sloodlemoduleid=" + (string)sloodlemoduleid, [HTTP_METHOD, "GET"], "");
  231. llSetTimerEvent(0.0);
  232. llSetTimerEvent(HTTP_TIMEOUT);
  233. }
  234. state_exit()
  235. {
  236. llSetTimerEvent(0.0);
  237. }
  238. timer()
  239. {
  240. llSetTimerEvent(0.0);
  241. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "httptimeout", [], NULL_KEY, "");
  242. llSleep(0.1);
  243. sloodle_reset();
  244. }
  245. http_response(key id, integer status, list meta, string body)
  246. {
  247. // Make sure this is the response we're expecting
  248. if (id != httpcheck) return;
  249. if (status != 200) {
  250. //sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "httperror:code", [status], NULL_KEY, "");
  251. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,status);
  252. sloodle_reset();
  253. return;
  254. }
  255. // Split the response into lines
  256. list lines = llParseStringKeepNulls(body, ["\n"], []);
  257. integer numlines = llGetListLength(lines);
  258. list statusfields = llParseStringKeepNulls(llList2String(lines, 0), ["|"], []);
  259. integer statuscode = (integer)llList2String(statusfields, 0);
  260. // Check the statuscode
  261. if (statuscode <= 0) {
  262. string errmsg = (string)statuscode;
  263. if (numlines > 1) errmsg += ": " + llList2String(lines, 1);
  264. //sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "servererror", [errmsg], NULL_KEY, "");
  265. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,statuscode);
  266. sloodle_reset();
  267. return;
  268. }
  269. // Make sure we have enough data
  270. if (numlines < 2) {
  271. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "badresponseformat", [], NULL_KEY, "");
  272. sloodle_reset();
  273. return;
  274. }
  275. // Store the glossary name
  276. sloodleglossaryname = llList2String(lines, 1);
  277. if (objChat==ON)
  278. sloodle_translation_request(SLOODLE_TRANSLATE_OWNER_SAY, [], "picturegloss:checkok", [sloodleglossaryname], NULL_KEY, "picturegloss");
  279. state ready;
  280. }
  281. }
  282. // Ready for definition requests
  283. state ready
  284. {
  285. on_rez( integer param)
  286. {
  287. state default;
  288. }
  289. link_message( integer sender_num, integer num, string str, key id)
  290. {
  291. // Check the channel
  292. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  293. // Is it a reset message?
  294. if (str == "do:reset") llResetScript();
  295. }
  296. }
  297. state_entry()
  298. {
  299. // Update the hover text
  300. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<1.0,0.0,0.0>, 0.9], "picturegloss:ready", [sloodleglossaryname, SLOODLE_METAGLOSS_COMMAND], NULL_KEY, "picturegloss");
  301. // Listen for chat messages
  302. llListen(0, "", NULL_KEY, "");
  303. llListen(SLOODLE_CHANNEL_AVATAR_DIALOG,"",llGetOwner(),"");
  304. // We may need to de-activate after a period of idle time
  305. llSetTimerEvent(0.0);
  306. if (sloodleidletimeout > 0) llSetTimerEvent((float)sloodleidletimeout);
  307. }
  308. touch_start(integer num_detected) {
  309. key id = llDetectedKey(0);
  310. integer canctrl = sloodle_check_access_ctrl(id);
  311. integer canuse = sloodle_check_access_use(id);
  312. if (!(canctrl || canuse)) return;
  313. //display menu for owner to turn off object chat
  314. list buttons = ["1","2"]; //maximum of 12!
  315. string translationLookup = "picturegloss:ctrlmenu"; //Turn object chat on or off
  316. list stringParams = ["1","2"];
  317. key uuidToSendDialogTo = llDetectedKey(0);
  318. sloodle_translation_request(SLOODLE_TRANSLATE_DIALOG, [SLOODLE_CHANNEL_AVATAR_DIALOG]+buttons, translationLookup, stringParams, uuidToSendDialogTo, "picturegloss");
  319. }
  320. state_exit()
  321. {
  322. llSetTimerEvent(0.0);
  323. }
  324. listen( integer channel, string name, key id, string message)
  325. {
  326. // Check the channel
  327. if (channel == 0) {
  328. // Check use of this object
  329. if (sloodle_check_access_use(id) == FALSE) return;
  330. // Is this a definition request?
  331. if (llSubStringIndex(message, SLOODLE_METAGLOSS_COMMAND) != 0) return;
  332. // Store the term to be searched and search it
  333. searchterm = llGetSubString(message, llStringLength(SLOODLE_METAGLOSS_COMMAND), -1);
  334. searcheruuid = id;
  335. state search;
  336. return;
  337. }else if (channel == SLOODLE_CHANNEL_AVATAR_DIALOG){
  338. if (message=="1"){
  339. objChat=ON;
  340. string batch = "picturegloss"; //the sloodle tool we are translating
  341. sloodle_translation_request(SLOODLE_TRANSLATE_OWNER_SAY, [], "picturegloss:objChat", ["ON"], NULL_KEY, batch);
  342. }else
  343. if (message=="2"){
  344. objChat=OFF;
  345. string batch = "picturegloss"; //the sloodle tool we are translating
  346. sloodle_translation_request(SLOODLE_TRANSLATE_OWNER_SAY, [], "picturegloss:objChat", ["OFF"], NULL_KEY, batch);
  347. }
  348. }
  349. }
  350. timer()
  351. {
  352. // Shutdown due to idle timeout
  353. state shutdown;
  354. }
  355. }
  356. state shutdown
  357. {
  358. on_rez(integer par)
  359. {
  360. state default;
  361. }
  362. link_message( integer sender_num, integer num, string str, key id)
  363. {
  364. // Check the channel
  365. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  366. // Is it a reset message?
  367. if (str == "do:reset") llResetScript();
  368. }
  369. }
  370. state_entry()
  371. {
  372. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.5,0.1,0.1>, 0.6], "picturegloss:idle", [sloodleglossaryname], NULL_KEY, "picturegloss");
  373. }
  374. touch_start(integer num_detected)
  375. {
  376. // Does this user have permission to use this object?
  377. if (sloodle_check_access_use(llDetectedKey(0))) {
  378. state ready;
  379. } else {
  380. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "nopermission:use", [], NULL_KEY, "");
  381. }
  382. }
  383. }
  384. state search
  385. {
  386. on_rez(integer par)
  387. {
  388. state default;
  389. }
  390. link_message( integer sender_num, integer num, string str, key id)
  391. {
  392. // Check the channel
  393. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  394. // Is it a reset message?
  395. if (str == "do:reset") llResetScript();
  396. }
  397. }
  398. state_entry()
  399. {
  400. // Search the specified term
  401. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<1.0,0.5,0.0>, 0.9], "picturegloss:searching", [sloodleglossaryname], NULL_KEY, "picturegloss");
  402. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  403. body += "&sloodlepwd=" + sloodlepwd;
  404. body += "&sloodlemoduleid=" + (string)sloodlemoduleid;
  405. body += "&sloodleuuid=" + (string)searcheruuid;
  406. body += "&sloodleavname=" + llEscapeURL(llKey2Name(searcheruuid));
  407. body += "&sloodleserveraccesslevel=" + (string)sloodleserveraccesslevel;
  408. body += "&sloodleterm=" + searchterm;
  409. body += "&sloodlepartialmatches=" + (string)sloodlepartialmatches;
  410. body += "&sloodlesearchaliases=" + (string)sloodlesearchaliases;
  411. body += "&sloodlesearchdefinitions=" + (string)sloodlesearchdefinitions;
  412. // Check if it's an object sending this message
  413. if (searcheruuid != llGetOwnerKey(searcheruuid)) {
  414. // This makes sure Moodle doesn't try to auto-register an object
  415. body += "&sloodleisobject=true";
  416. }
  417. // Send the request
  418. httpsearch = llHTTPRequest(sloodleserverroot + SLOODLE_GLOSSARY_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body);
  419. llSetTimerEvent(0.0);
  420. llSetTimerEvent(HTTP_TIMEOUT);
  421. }
  422. state_exit()
  423. {
  424. llSetTimerEvent(0.0);
  425. }
  426. timer()
  427. {
  428. llSetTimerEvent(0.0);
  429. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "httptimeout", [], NULL_KEY, "");
  430. state ready;
  431. }
  432. http_response(key id, integer status, list meta, string body)
  433. {
  434. // Make sure this is the response we're expecting
  435. if (id != httpsearch) {
  436. return;
  437. }
  438. httpsearch = NULL_KEY;
  439. llSetTimerEvent(0.0);
  440. if (status != 200) {
  441. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "httperror:code", [status], NULL_KEY, "");
  442. state ready;
  443. return;
  444. }
  445. // Split the response into lines
  446. list lines = llParseStringKeepNulls(body, ["\n"], []);
  447. integer numlines = llGetListLength(lines);
  448. list statusfields = llParseStringKeepNulls(llList2String(lines, 0), ["|"], []);
  449. integer statuscode = (integer)llList2String(statusfields, 0);
  450. // Check the statuscode
  451. if (statuscode <= 0) {
  452. string errmsg = (string)statuscode;
  453. if (numlines > 1) errmsg += ": " + llList2String(lines, 1);
  454. // sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "servererror", [errmsg], NULL_KEY, "");
  455. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,statuscode);
  456. state ready;
  457. return;
  458. }
  459. // Indicate how many definitions were found
  460. if (objChat ==ON)
  461. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "picturegloss:numdefs", [searchterm, (numlines - 1)], NULL_KEY, "picturegloss");
  462. // Go through each definition
  463. integer defnum = 1;
  464. list fields = [];
  465. for (; defnum < numlines; defnum++) {
  466. // Split this definition into fields
  467. fields = llParseStringKeepNulls(llList2String(lines, defnum), ["|"], []);
  468. if (llGetListLength(fields) >= 2) {
  469. // llSay(0, llList2String(fields, 0) + " = " + llList2String(fields, 1));
  470. //-------------------
  471. //The definition is spoken here - and here is hte added code
  472. list TextureList=llParseString2List(llList2String(fields, 1),[":"],[]);
  473. // Make sure the appropriate number of fields have been specified
  474. if (llGetListLength(TextureList) >= 3) {
  475. string TextureUUID=llList2String(TextureList,0);
  476. string PrimScaleWidth=llList2String(TextureList,1);
  477. string PrimScaleHeight=llList2String(TextureList,2);
  478. llOwnerSay(TextureUUID+"/"+PrimScaleWidth+"/"+PrimScaleHeight);
  479. llSetTexture( llStringTrim( TextureUUID, STRING_TRIM) , ALL_SIDES);
  480. llSetPrimitiveParams([PRIM_SIZE,<(integer)PrimScaleWidth/100,(integer)PrimScaleWidth/100,(integer)PrimScaleHeight/100>]);
  481. } else {
  482. llSay(0, "ERROR: invalid texture data in glossary. Please ensure the definition has the format \"UUID:width:height\".");
  483. }
  484. //------------------------
  485. } else {
  486. // llSay(0, llList2String(fields, 0));
  487. }
  488. }
  489. state ready;
  490. }
  491. }
  492. // Please leave the following line intact to show where the script lives in Git:
  493. // SLOODLE LSL Script Git Location: mod/picturegloss-1.0/objects/default/assets/sloodle_mod_glossary-1.0.lslp