sloodle_mod_presenter-1.0.lslp.os 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. // Sloodle Presenter (for Sloodle 0.4.1)
  2. // Lets the educator display a presentation of images. videos and webpages hosted on the web.
  3. // Part of the Sloodle project (www.sloodle.org)
  4. //
  5. // Copyright (c) 2008-9 Sloodle project contributors
  6. // Released under the GNU GPL
  7. //
  8. // Contributors:
  9. // Peter R. Bloomfield
  10. // Paul G. Preibisch (Fire Centaur)
  11. //
  12. integer SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST=-1828374651; // this channel is used to send status codes for translation to the error_messages lsl script
  13. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;
  14. string SLOODLE_PRESENTER_LINKER = "/mod/sloodle/mod/presenter-2.0/linker.php";
  15. string SLOODLE_EOF = "sloodleeof";
  16. list parcelInfo = []; //var for parcel owner
  17. integer MENU_CHANNEL = -1;
  18. string SLOODLE_OBJECT_TYPE = "presenter-2.0";
  19. integer reset;
  20. integer SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC = 0;
  21. integer SLOODLE_OBJECT_ACCESS_LEVEL_OWNER = 1;
  22. integer SLOODLE_OBJECT_ACCESS_LEVEL_GROUP = 2;
  23. string sloodleserverroot = "";
  24. string sloodlepwd = "";
  25. integer sloodlecontrollerid = 0;
  26. integer sloodlemoduleid = 0;
  27. integer sloodleobjectaccesslevelctrl = 1; // Who can control this object?
  28. string PRESENTER_TEXTURE= "sloodle_presenter_texture";
  29. integer isconfigured = FALSE; // Do we have all the configuration data we need?
  30. integer eof = FALSE; // Have we reached the end of the configuration data?
  31. key httploadpresentation = NULL_KEY; // Request for presentation data
  32. string presentername = ""; // The name of the Presenter
  33. integer numslides = 0; // Total number of slides in the presentation
  34. integer curslidenum = 0; // Number of the current slide in the presentation (starting from 1)
  35. string curslidetype = ""; // Mimetype of the current slide
  36. string curslidesource = ""; // Source of the current slide media (usually a URL)
  37. string curslidename = ""; // Name of the current slide
  38. // requestConfigData = 0 this is set to 1 after the presenter has been deeded - afterwhich if "update" is
  39. // selected, the presenter will go back into the default state and re-request config data. This is necessary since the teacher may change prentations the presenter is pointing to via the web.
  40. integer requestConfigData = 0;
  41. ///// TRANSLATION /////
  42. // Link message channels
  43. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
  44. integer SLOODLE_CHANNEL_TRANSLATION_RESPONSE = -1928374652;
  45. // Translation output methods
  46. string SLOODLE_TRANSLATE_LINK = "link"; // No output parameters - simply returns the translation on SLOODLE_TRANSLATION_RESPONSE link message channel
  47. string SLOODLE_TRANSLATE_SAY = "say"; // 1 output parameter: chat channel number
  48. string SLOODLE_TRANSLATE_WHISPER = "whisper"; // 1 output parameter: chat channel number
  49. string SLOODLE_TRANSLATE_SHOUT = "shout"; // 1 output parameter: chat channel number
  50. string SLOODLE_TRANSLATE_REGION_SAY = "regionsay"; // 1 output parameter: chat channel number
  51. string SLOODLE_TRANSLATE_OWNER_SAY = "ownersay"; // No output parameters
  52. 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.
  53. string SLOODLE_TRANSLATE_LOAD_URL = "loadurl"; // Recipient avatar should be identified in link message keyval. 1 output parameter giving URL to load.
  54. string SLOODLE_TRANSLATE_HOVER_TEXT = "hovertext"; // 2 output parameters: colour <r,g,b>, and alpha value
  55. string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
  56. string SLOODLE_TRANSLATE_HOVER_TEXT_BASIC = "hovertextbasic";
  57. key myOwnerKey;
  58. string transMethod; //constant to identify why type of translation we want to configure - dialog, hovertext etc
  59. list menuChannel; //useful var to configure a sloodle_request_translation - channel dialog will chat responses on
  60. list btns; //useful var to configure a sloodle_request_translation - buttons for the dialog
  61. string transString; //useful var to configure a sloodle_request_translation - the local translation string in the translation script
  62. key destinationKey; //useful var to configure a sloodle_request_translation - who we send the dialog to
  63. string translationModule; //useful var to configure a sloodle_request_translation - in this case - the "presenter"
  64. // Send a translation request link message
  65. sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch)
  66. {
  67. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
  68. }
  69. ///// ----------- /////
  70. ///// FUNCTIONS /////
  71. /******************************************************************************************************************************
  72. * sloodle_error_code -
  73. * Author: Paul Preibisch
  74. * Description - This function sends a linked message on the SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST channel
  75. * The error_messages script hears this, translates the status code and sends an instant message to the avuuid
  76. * Params: method - SLOODLE_TRANSLATE_SAY, SLOODLE_TRANSLATE_IM etc
  77. * Params: avuuid - this is the avatar UUID to that an instant message with the translated error code will be sent to
  78. * Params: status code - the status code of the error as on our wiki: http://slisweb.sjsu.edu/sl/index.php/Sloodle_status_codes
  79. *******************************************************************************************************************************/
  80. sloodle_error_code(string method, key avuuid,integer statuscode){
  81. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST, method+"|"+(string)avuuid+"|"+(string)statuscode, NULL_KEY);
  82. }
  83. // Just returns a random integer - used for setting channels
  84. integer random_integer( integer min, integer max )
  85. {
  86. return min + (integer)( llFrand( max - min + 1 ) );
  87. }
  88. sloodle_debug(string msg)
  89. {
  90. llMessageLinked(LINK_THIS, DEBUG_CHANNEL, msg, NULL_KEY);
  91. }
  92. // Configure by receiving a linked message from another script in the object
  93. // Returns TRUE if the object has all the data it needs
  94. integer sloodle_handle_command(string str)
  95. {
  96. list bits = llParseString2List(str,["|"],[]);
  97. integer numbits = llGetListLength(bits);
  98. string name = llList2String(bits,0);
  99. string value1 = "";
  100. string value2 = "";
  101. if (numbits > 1) value1 = llList2String(bits,1);
  102. if (numbits > 2) value2 = llList2String(bits,2);
  103. if (name == "set:sloodleserverroot") sloodleserverroot = value1;
  104. else if (name == "set:sloodlepwd") {
  105. // The password may be a single prim password, or a UUID and a password
  106. if (value2 != "") sloodlepwd = value1 + "|" + value2;
  107. else sloodlepwd = value1;
  108. } else if (name == "set:sloodlecontrollerid") sloodlecontrollerid = (integer)value1;
  109. else if (name == "set:sloodlemoduleid") sloodlemoduleid = (integer)value1;
  110. else if (name == "set:sloodleobjectaccesslevelctrl") sloodleobjectaccesslevelctrl = (integer)value1;
  111. else if (name == SLOODLE_EOF) eof = TRUE;
  112. return (sloodleserverroot != "" && sloodlepwd != "" && sloodlecontrollerid > 0 && sloodlemoduleid > 0);
  113. }
  114. // Checks if the given agent is permitted to control this object
  115. // Returns TRUE if so, or FALSE if not
  116. integer sloodle_check_access_ctrl(key id)
  117. {
  118. // Check the access mode
  119. if (sloodleobjectaccesslevelctrl == SLOODLE_OBJECT_ACCESS_LEVEL_GROUP) {
  120. return llSameGroup(id);
  121. } else if (sloodleobjectaccesslevelctrl == SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC) {
  122. return TRUE;
  123. }
  124. // Assume it's owner mode
  125. return (id == llGetOwner());
  126. }
  127. // Update the image display (e.g. change the parcel media URL).
  128. // Does nothing if the data we currently have isn't valid
  129. update_image_display()
  130. {
  131. // Make sure an error didn't occur with the slide plugin
  132. if (curslidetype == "ERROR") return;
  133. // Make sure we have a valid slide number and valid data
  134. if (curslidenum < 1 || curslidenum > numslides) return;
  135. if (curslidetype == "" || curslidesource == "") return;
  136. // If we expand this to include the display of non-media channel content, then check the type here.
  137. // Set the parcel media
  138. llParcelMediaCommandList([
  139. PARCEL_MEDIA_COMMAND_TYPE, curslidetype,
  140. PARCEL_MEDIA_COMMAND_URL, curslidesource
  141. ]);
  142. }
  143. // Request the specified slide
  144. request_slide(integer num)
  145. {
  146. // Indicate that we are requesting a slide
  147. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<1.29037, 1.42417, 0.00000>, 0.9], "loadingslide", [num], NULL_KEY, "presenter");
  148. // Construct and send our HTTP request for data
  149. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  150. body += "&sloodlepwd=" + sloodlepwd;
  151. body += "&sloodlemoduleid=" + (string)sloodlemoduleid;
  152. body += "&sloodleslidenum=" + (string)num;
  153. httploadpresentation = llHTTPRequest(sloodleserverroot + SLOODLE_PRESENTER_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body);
  154. llSetTimerEvent(8.0);
  155. }
  156. // Move to the next slide
  157. next_slide()
  158. {
  159. if (curslidenum < 1 || curslidenum >= numslides) request_slide(1);
  160. else request_slide(curslidenum + 1);
  161. }
  162. // Move to the previous slide
  163. previous_slide()
  164. {
  165. if (curslidenum <= 1 || curslidenum > numslides) request_slide(numslides);
  166. else request_slide(curslidenum - 1);
  167. }
  168. // Update the hover text to indicate which image is being displayed
  169. update_hover_text()
  170. {
  171. // Make sure we actually have some slide data
  172. if (numslides == 0) {
  173. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.5, 0.0, 0.0>, 1.0], "error:nodata", [], NULL_KEY, "presenter");
  174. return;
  175. }
  176. // Make sure an error didn't occur with the slide plugin
  177. if (curslidetype == "ERROR") {
  178. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.5, 0.0, 0.0>, 1.0], "error:pluginnotfound", [presentername, curslidenum, numslides], NULL_KEY, "presenter");
  179. return;
  180. }
  181. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0, 1.0, 0.0>, 1.0], "showingslidename", [presentername, curslidenum, numslides, curslidename], NULL_KEY, "presenter");
  182. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "showingentryurl", [curslidenum, numslides, curslidesource], NULL_KEY, "presenter");
  183. }
  184. ///// STATES /////
  185. // Default state - waiting for configuration
  186. // Default state - waiting for configuration
  187. default{
  188. on_rez(integer start_param) {
  189. myOwnerKey = llGetOwner();
  190. }
  191. state_entry() {
  192. myOwnerKey = llGetOwner();
  193. llOwnerSay("Owner set to: " + llKey2Name(llGetOwner())+ " with UUID: " + (string)llGetOwner());
  194. reset=FALSE; //used in the last state - if someone deletes the sloodle_presenter_texture, we set a timer, so need to distinguish in timer event, what to do - ie: was the timer set because the texture was deleted? then set reset to TRUE.
  195. state initialize;
  196. }
  197. }
  198. state initialize
  199. {
  200. on_rez(integer start_param) {
  201. llOwnerSay("Reseting...");
  202. myOwnerKey = llGetOwner();
  203. llResetScript();
  204. }
  205. state_entry()
  206. {
  207. if ((string)llGetInventoryKey("sloodle_config")!="00000000-0000-0000-0000-000000000000")
  208. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.00000,1, 0>, 1.0], "touchforwebconfig", [], NULL_KEY, "presenter");
  209. // Starting again with a new configuration
  210. llSetText("", <0.0,0.0,0.0>, 0.0);
  211. isconfigured = FALSE;
  212. eof = FALSE;
  213. // Reset our data
  214. sloodleserverroot = "";
  215. sloodlepwd = "";
  216. sloodlecontrollerid = 0;
  217. sloodlemoduleid = 0;
  218. sloodleobjectaccesslevelctrl = 0;
  219. if (requestConfigData==1){
  220. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:requestconfig", NULL_KEY);
  221. }
  222. requestConfigData=1;
  223. }
  224. link_message( integer sender_num, integer num, string str, key id)
  225. {
  226. // Check the channel
  227. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  228. // Split the message into lines
  229. list lines = llParseString2List(str, ["\n"], []);
  230. integer numlines = llGetListLength(lines);
  231. integer i;
  232. for (i = 0; i < numlines; i++) {
  233. isconfigured = sloodle_handle_command(llList2String(lines, i));
  234. }
  235. // If we've got all our data AND reached the end of the configuration data, then move on
  236. if (eof == TRUE) {
  237. if (isconfigured == TRUE) {
  238. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configurationreceived", [], NULL_KEY, "");
  239. state checkParcelOwner;
  240. } else {
  241. // Go all configuration but, it's not complete... request reconfiguration
  242. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configdatamissing", [], NULL_KEY, "");
  243. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
  244. eof = FALSE;
  245. }
  246. }
  247. }
  248. }
  249. touch_start(integer num_detected)
  250. {
  251. // Attempt to request a reconfiguration
  252. //if (llDetectedKey(0) == llGetOwner()) {
  253. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:requestconfig", NULL_KEY);
  254. //}
  255. }
  256. }
  257. state checkParcelOwner
  258. {
  259. state_entry() {
  260. MENU_CHANNEL = random_integer(10000,20000); //set channel for config menu
  261. parcelInfo = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_OWNER]);
  262. if (llList2Key(parcelInfo,0) != llGetOwner()){
  263. string errorMessage ="This Presenter MUST be deeded to the Parcel Owner for it to display your presentation";
  264. llSetText(errorMessage, <0.92748, 0.00000, 0.42705>,100 );
  265. llDialog(llGetOwner(),errorMessage, ["help"], MENU_CHANNEL);
  266. } else {
  267. llSay(0,"Presenter Parcel Settings are Correct! Retreiving Slides..");
  268. state setMediaTexture;
  269. }
  270. llListen(MENU_CHANNEL, "", llGetOwner(), "");
  271. llSetTimerEvent(300);
  272. }
  273. listen(integer channel, string name, key id, string message) {
  274. if (channel == MENU_CHANNEL){
  275. if (message=="help"){
  276. llGiveInventory(id,"Presenter Help");
  277. }
  278. }
  279. }
  280. touch_start(integer num_detected) {
  281. parcelInfo = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_OWNER]);
  282. if (llList2Key(parcelInfo,0) != llGetOwner()){
  283. llDialog(llGetOwner(),"This Presenter MUST be deeded to the Parcel Owner for it to display your presentation", ["help"], MENU_CHANNEL);
  284. } else {
  285. llSay(0,"Presenter Parcel Settings are Correct! Retreiving Slides..");
  286. state setMediaTexture;
  287. }
  288. }
  289. timer() {
  290. state checkParcelOwnerAgain;
  291. }
  292. state_exit() {
  293. llSetText("",<0.92748, 0.00000, 0.42705>, 100);
  294. }
  295. }
  296. state checkParcelOwnerAgain
  297. {
  298. state_entry()
  299. {
  300. state checkParcelOwner;
  301. }
  302. }
  303. state setMediaTexture
  304. {
  305. state_entry() {
  306. if ((string)llGetInventoryKey(PRESENTER_TEXTURE)=="00000000-0000-0000-0000-000000000000"){
  307. //string,list,list,string,list,key,list
  308. transMethod= SLOODLE_TRANSLATE_DIALOG;
  309. btns = ["Reset"];
  310. transString = "missingsloodletexture";
  311. llSay(0,(string)myOwnerKey);
  312. destinationKey=myOwnerKey;
  313. translationModule="presenter";
  314. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "missingsloodletexture", [], NULL_KEY, "presenter");
  315. }else{
  316. llSetTexture(PRESENTER_TEXTURE,ALL_SIDES);
  317. llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_TEXTURE,llGetInventoryKey(PRESENTER_TEXTURE)]); //set texture to presenter texture
  318. llSay(0,"Parcel Media texture set to "+PRESENTER_TEXTURE);
  319. //set autoscale
  320. llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_AUTO_ALIGN,TRUE]);
  321. state running;
  322. }
  323. }
  324. touch_start(integer num_detected) {
  325. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "checkinginventory", [], NULL_KEY, "presenter");
  326. if ((string)llGetInventoryKey(PRESENTER_TEXTURE)=="00000000-0000-0000-0000-000000000000"){
  327. transString = "stilldoesntexistininventory";
  328. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "missingsloodletexture", [], NULL_KEY, "presenter");
  329. }
  330. else {
  331. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "foundsloodletexture", [], NULL_KEY, "presenter");
  332. llResetScript();
  333. }
  334. }
  335. /***********************************************
  336. * changed event
  337. * |-->Every time the inventory changes, reset the script
  338. *
  339. ***********************************************/
  340. changed(integer change) {
  341. if (change ==CHANGED_INVENTORY){
  342. if ((string)llGetInventoryKey(PRESENTER_TEXTURE)=="00000000-0000-0000-0000-000000000000"){
  343. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "stilldoesntexistininventory", [], NULL_KEY, "presenter");
  344. }else{
  345. llSetTexture(PRESENTER_TEXTURE,ALL_SIDES);
  346. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "foundsloodletexture", [], NULL_KEY, "presenter");
  347. llSetTimerEvent(3.0);
  348. }
  349. }
  350. }
  351. timer() {
  352. llSetTimerEvent(0.0);
  353. llResetScript();
  354. }
  355. }
  356. state running
  357. {
  358. state_entry()
  359. {
  360. // Request the first slide
  361. request_slide(1);
  362. }
  363. state_exit()
  364. {
  365. llSetText("", <0.0, 0.0, 0.0>, 0.0);
  366. llSetTimerEvent(0.0);
  367. }
  368. touch_start(integer num)
  369. {
  370. // Find out what was touched
  371. string buttonname = llGetLinkName(llDetectedLinkNumber(0));
  372. if (buttonname == "next") {
  373. next_slide();
  374. } else if (buttonname == "previous") {
  375. previous_slide();
  376. } else if (buttonname == "reset") {
  377. request_slide(1);
  378. } else if (buttonname == "update") {
  379. requestConfigData=1; // in default data state request config data to ensure
  380. //controller settings proliferate into SL - ie: someone changed the presentation this presenter is pointing to via the requestConfigData=1; // in default data state request config data to ensure
  381. //controller settings proliferate into SL - ie: someone changed the presentation this presenter is pointing to via the web
  382. state default;
  383. }
  384. }
  385. on_rez(integer par) { llResetScript(); }
  386. timer()
  387. {
  388. llSetTimerEvent(0.0);
  389. if (reset==TRUE){
  390. reset=FALSE;
  391. llResetScript();
  392. }else{
  393. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "httptimeout", [], NULL_KEY, "");
  394. update_hover_text();
  395. update_image_display();
  396. }
  397. }
  398. http_response(key id, integer status, list meta, string body)
  399. {
  400. // Is this the expected data?
  401. if (id != httploadpresentation) {
  402. return;
  403. }
  404. httploadpresentation = NULL_KEY;
  405. llSetTimerEvent(0.0);
  406. // Make sure the request worked
  407. if (status != 200) {
  408. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,status); //send message to error_message.lsl
  409. return;
  410. }
  411. // Make sure there is a body to the request
  412. if (body == "") {
  413. sloodle_debug("Body of HTTP response was empty.");
  414. return;
  415. }
  416. // Split the data up into lines
  417. list lines = llParseStringKeepNulls(body, ["\n"], []);
  418. integer numlines = llGetListLength(lines);
  419. if (numlines < 2) {
  420. sloodle_debug("HTTP response contained only 1 line - expected at least 2 for a correctly formatted response.");
  421. return;
  422. }
  423. // Extract all the status fields
  424. list statusfields = llParseStringKeepNulls( llList2String(lines,0), ["|"], [] );
  425. // Get the statuscode
  426. integer statuscode = llList2Integer(statusfields,0);
  427. // Was it an error code?
  428. if (statuscode == -131) {
  429. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0, 1.0, 0.0>, 1.0], "error:noplugins", [], NULL_KEY, "presenter");
  430. return;
  431. } else if (statuscode == -10501) {
  432. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0, 1.0, 0.0>, 1.0], "error:noslides", [], NULL_KEY, "presenter");
  433. return;
  434. } else if (statuscode <= 0) {
  435. // Do we have an error message to go with it?
  436. if (numlines > 1) {
  437. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "sloodleerror:desc", [statuscode, llList2String(lines, 1)], NULL_KEY, "");
  438. } else {
  439. // sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "sloodleerror", [statuscode], NULL_KEY, "");
  440. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,statuscode); //send message to error_message.lsl
  441. }
  442. return;
  443. }
  444. // The first data line contains two things: the number of slides, and the name of the Presenter
  445. list fields = llParseStringKeepNulls(llList2String(lines, 1), ["|"], []);
  446. if (llGetListLength(fields) < 2) {
  447. sloodle_debug("Expected at least 2 fields on first data line.");
  448. return;
  449. }
  450. numslides = (integer)llList2String(fields, 0);
  451. presentername = llList2String(fields, 1);
  452. fields = [];
  453. // Make sure we have another line, which will be the current slide data.
  454. if (numlines < 3) {
  455. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0, 1.0, 0.0>, 1.0], "error:noslides", [], NULL_KEY, "presenter");
  456. return;
  457. }
  458. // This line should contain at least 4 fields: num | type | source | name.
  459. // If the "type" value is "ERROR" then the plugin could not be loaded.
  460. fields = llParseStringKeepNulls(llList2String(lines, 2), ["|"], []);
  461. if (llGetListLength(fields) < 4) {
  462. sloodle_debug("Expected at least 4 fields of slide data in second data line.");
  463. return;
  464. }
  465. curslidenum = (integer)llList2String(fields, 0);
  466. curslidetype = llList2String(fields, 1);
  467. curslidesource = llList2String(fields, 2);
  468. curslidename = llList2String(fields, 3);
  469. // Now that we've got all that data, update the display
  470. update_hover_text();
  471. update_image_display();
  472. }
  473. /***********************************************
  474. * changed event
  475. * |-->Every time the inventory changes, reset the script
  476. *
  477. ***********************************************/
  478. changed(integer change) {
  479. if (change ==CHANGED_INVENTORY){
  480. if ((string)llGetInventoryKey(PRESENTER_TEXTURE)=="00000000-0000-0000-0000-000000000000"){
  481. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "stilldoesntexistininventory", [], NULL_KEY, "presenter");
  482. }else{
  483. llSetTexture(PRESENTER_TEXTURE,ALL_SIDES);
  484. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "foundsloodletexture", [], NULL_KEY, "presenter");
  485. reset=TRUE;
  486. llSetTimerEvent(3.0);
  487. }
  488. }
  489. }
  490. }
  491. // Please leave the following line intact to show where the script lives in Git:
  492. // SLOODLE LSL Script Git Location: mod/presenter-1.0/sloodle_mod_presenter-1.0.lsl.os