sloodle_mod_presenter-2.0.lslp 23 KB

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