sloodle_mod_presenter-1.0.lslp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. // Sloodle Presenter (for Sloodle 0.4)
  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 Sloodle
  8. // Released under the GNU GPL
  9. //
  10. // Contributors:
  11. // Peter R. Bloomfield
  12. // Paul G. Preibisch (Fire Centaur)
  13. // dz questi - youtube contrib
  14. //
  15. integer SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST=-1828374651; // this channel is used to send status codes for translation to the error_messages lsl script
  16. string mediaurl;
  17. string vidid;
  18. integer index;
  19. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;
  20. string SLOODLE_SLIDESHOW_LINKER = "/mod/sloodle/mod/presenter-1.0/linker.php";
  21. string SLOODLE_EOF = "sloodleeof";
  22. list parcelInfo; //var for parcel owner
  23. integer MENU_CHANNEL;
  24. string SLOODLE_OBJECT_TYPE = "presenter-1.0";
  25. integer deedNoticeCount=0;
  26. integer SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC = 0;
  27. integer SLOODLE_OBJECT_ACCESS_LEVEL_OWNER = 1;
  28. integer SLOODLE_OBJECT_ACCESS_LEVEL_GROUP = 2;
  29. string transMethod; //constant to identify why type of translation we want to configure - dialog, hovertext etc
  30. list menuChannel; //useful var to configure a sloodle_request_translation - channel dialog will chat responses on
  31. list btns; //useful var to configure a sloodle_request_translation - buttons for the dialog
  32. string transString; //useful var to configure a sloodle_request_translation - the local translation string in the translation script
  33. key destinationKey; //useful var to configure a sloodle_request_translation - who we send the dialog to
  34. string translationModule; //useful var to configure a sloodle_request_translation - in this case - the "presenter"
  35. string PRESENTER_TEXTURE="sloodle_presenter_texture";
  36. string sloodleserverroot = "";
  37. string sloodlepwd = "";
  38. integer sloodlecontrollerid = 0;
  39. integer sloodlemoduleid = 0;
  40. integer sloodleobjectaccesslevelctrl = 1; // Who can control this object?
  41. integer isconfigured = FALSE; // Do we have all the configuration data we need?
  42. integer eof = FALSE; // Have we reached the end of the configuration data?
  43. key httpentries = NULL_KEY; // Request for list of entries
  44. list entrytypes = []; // List of current entry types
  45. list entryurls = []; // List of current entry URLs
  46. list entrynames = []; // List of current entry names
  47. integer currententry = 0; // Array ID identifying which entry in the lists (entrytypes and entryurls) we are currently viewing
  48. ///// TRANSLATION /////
  49. // Link message channels
  50. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
  51. integer SLOODLE_CHANNEL_TRANSLATION_RESPONSE = -1928374652;
  52. // Translation output methods
  53. string SLOODLE_TRANSLATE_LINK = "link"; // No output parameters - simply returns the translation on SLOODLE_TRANSLATION_RESPONSE link message channel
  54. string SLOODLE_TRANSLATE_SAY = "say"; // 1 output parameter: chat channel number
  55. string SLOODLE_TRANSLATE_WHISPER = "whisper"; // 1 output parameter: chat channel number
  56. string SLOODLE_TRANSLATE_SHOUT = "shout"; // 1 output parameter: chat channel number
  57. string SLOODLE_TRANSLATE_REGION_SAY = "regionsay"; // 1 output parameter: chat channel number
  58. string SLOODLE_TRANSLATE_OWNER_SAY = "ownersay"; // No output parameters
  59. 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.
  60. string SLOODLE_TRANSLATE_LOAD_URL = "loadurl"; // Recipient avatar should be identified in link message keyval. 1 output parameter giving URL to load.
  61. string SLOODLE_TRANSLATE_HOVER_TEXT = "hovertext"; // 2 output parameters: colour <r,g,b>, and alpha value
  62. string SLOODLE_TRANSLATE_HOVER_TEXT_BASIC = "hovertextbasic";
  63. string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
  64. //requestConfigData = 0 this is set to 1 after the presenter has been deeded - afterwhich if "update" is
  65. //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.
  66. // Send a translation request link message
  67. integer requestConfigData=0;
  68. key myOwnerKey;
  69. sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch)
  70. {
  71. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
  72. }
  73. ///// ----------- /////
  74. ///// FUNCTIONS /////
  75. /******************************************************************************************************************************
  76. * sloodle_error_code -
  77. * Author: Paul Preibisch
  78. * Description - This function sends a linked message on the SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST channel
  79. * The error_messages script hears this, translates the status code and sends an instant message to the avuuid
  80. * Params: method - SLOODLE_TRANSLATE_SAY, SLOODLE_TRANSLATE_IM etc
  81. * Params: avuuid - this is the avatar UUID to that an instant message with the translated error code will be sent to
  82. * Params: status code - the status code of the error as on our wiki: http://slisweb.sjsu.edu/sl/index.php/Sloodle_status_codes
  83. *******************************************************************************************************************************/
  84. sloodle_error_code(string method, key avuuid,integer statuscode){
  85. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST, method+"|"+(string)avuuid+"|"+(string)statuscode, NULL_KEY);
  86. }
  87. /***********************************************
  88. * random_integer()
  89. * |-->Produces a random integer
  90. ***********************************************/
  91. integer random_integer( integer min, integer max )
  92. {
  93. return min + (integer)( llFrand( max - min + 1 ) );
  94. }
  95. sloodle_debug(string msg)
  96. {
  97. llMessageLinked(LINK_THIS, DEBUG_CHANNEL, msg, NULL_KEY);
  98. }
  99. // Configure by receiving a linked message from another script in the object
  100. // Returns TRUE if the object has all the data it needs
  101. integer sloodle_handle_command(string str)
  102. {
  103. list bits = llParseString2List(str,["|"],[]);
  104. integer numbits = llGetListLength(bits);
  105. string name = llList2String(bits,0);
  106. string value1 = "";
  107. string value2 = "";
  108. if (numbits > 1) value1 = llList2String(bits,1);
  109. if (numbits > 2) value2 = llList2String(bits,2);
  110. if (name == "set:sloodleserverroot") sloodleserverroot = value1;
  111. else if (name == "set:sloodlepwd") {
  112. // The password may be a single prim password, or a UUID and a password
  113. if (value2 != "") sloodlepwd = value1 + "|" + value2;
  114. else sloodlepwd = value1;
  115. } else if (name == "set:sloodlecontrollerid") sloodlecontrollerid = (integer)value1;
  116. else if (name == "set:sloodlemoduleid") sloodlemoduleid = (integer)value1;
  117. else if (name == "set:sloodleobjectaccesslevelctrl") sloodleobjectaccesslevelctrl = (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 == myOwnerKey);
  133. }
  134. // Update the image display (change the parcel media URL).
  135. // Does nothing if the current image ID is invalid.
  136. update_image_display()
  137. {
  138. // Figure out what type to use
  139. string typename = llList2String(entrytypes, currententry);
  140. string type = "";
  141. if (typename == "image") type = "image/*";
  142. else if (typename == "video") {
  143. if (~llSubStringIndex(llList2String(entryurls, currententry), "http://www.youtube.com") || ~llSubStringIndex(llList2String(entryurls, currententry), "http://youtube.com"))
  144. {
  145. //turn the data into a vidid
  146. index = llSubStringIndex(llList2String(entryurls, currententry), "v=");
  147. vidid = llGetSubString(llList2String(entryurls, currententry), index + 2, index + 12);;
  148. mediaurl = "http://www.youtubemp4.com/video/"+vidid+".mp4";
  149. type = "video/mp4";
  150. // Set the parcel media
  151. llParcelMediaCommandList([
  152. PARCEL_MEDIA_COMMAND_TYPE, type,
  153. PARCEL_MEDIA_COMMAND_URL, mediaurl
  154. ]);
  155. return;
  156. }else type = "video/*";
  157. }
  158. else if (typename == "audio") type = "audio/*";
  159. else type = "text/html";
  160. // Set the parcel media
  161. llParcelMediaCommandList([
  162. PARCEL_MEDIA_COMMAND_TYPE, type,
  163. PARCEL_MEDIA_COMMAND_URL, llList2String(entryurls, currententry)
  164. ]);
  165. }
  166. // Move to the next image
  167. next_image()
  168. {
  169. currententry = ((currententry + 1) % llGetListLength(entryurls));
  170. sloodle_update_hover_text();
  171. update_image_display();
  172. }
  173. // Move to the previous image
  174. previous_image()
  175. {
  176. currententry = currententry - 1;
  177. if (currententry < 0) currententry = llGetListLength(entryurls) - 1;
  178. sloodle_update_hover_text();
  179. update_image_display();
  180. }
  181. // Update the hover text to indicate which image is being displayed
  182. sloodle_update_hover_text()
  183. {
  184. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<0.0, 1.0, 0.0>, 1.0], "showingentryname", [(currententry + 1), llGetListLength(entryurls), llList2String(entrynames, currententry)], NULL_KEY, "presenter");
  185. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "showingentryurl", [(currententry + 1), llGetListLength(entryurls), llList2String(entryurls, currententry)], NULL_KEY, "presenter");
  186. }
  187. // Default state - waiting for configuration
  188. default{
  189. on_rez(integer start_param) {
  190. myOwnerKey = llGetOwner();
  191. }
  192. state_entry() {
  193. myOwnerKey = llGetOwner();
  194. llOwnerSay("Owner set to: " + llKey2Name(llGetOwner())+ " with UUID: " + (string)llGetOwner());
  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 = 0;
  232. for (; 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. //check if sloodle_presenter_texture exists
  240. state checkParcelOwner;
  241. } else {
  242. // Go all configuration but, it's not complete... request reconfiguration
  243. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configdatamissing", [], NULL_KEY, "");
  244. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
  245. eof = FALSE;
  246. }
  247. }
  248. }
  249. }
  250. touch_start(integer num_detected)
  251. {
  252. // Attempt to request a reconfiguration
  253. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:requestconfig", NULL_KEY);
  254. }
  255. }
  256. state checkParcelOwner
  257. {
  258. state_entry() {
  259. MENU_CHANNEL = random_integer(10000,20000); //set channel for config menu
  260. parcelInfo = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_OWNER]);
  261. if (llList2Key(parcelInfo,0) != llGetOwner()){
  262. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "mustbedeeded", [], NULL_KEY, "presenter");
  263. } else {
  264. llSay(0,"Presenter Parcel Settings are Correct! Loading media texture....");
  265. state setMediaTexture;
  266. }
  267. llListen(MENU_CHANNEL, "", llGetOwner(), "");
  268. llSetTimerEvent(300);
  269. }
  270. listen(integer channel, string name, key id, string message) {
  271. if (channel == MENU_CHANNEL){
  272. if (message=="help"){
  273. llGiveInventory(id,"Presenter Help");
  274. }
  275. }
  276. }
  277. touch_start(integer num_detected) {
  278. parcelInfo = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_OWNER]);
  279. if (llList2Key(parcelInfo,0) != llGetOwner()){
  280. llDialog(llGetOwner(),"This Presenter MUST be deeded to the Parcel Owner for it to display your presentation", ["help"], MENU_CHANNEL);
  281. } else {
  282. //only send a dialog notice 3 times so we don't annoy the owner!
  283. if (deedNoticeCount<3){
  284. llSay(0,"Presenter Parcel Settings are Correct! Retreiving Slides..");
  285. deedNoticeCount++;
  286. }
  287. state setMediaTexture;
  288. }
  289. }
  290. timer() {
  291. state checkParcelOwnerAgain;
  292. }
  293. state_exit() {
  294. llSetText("",<0.92748, 0.00000, 0.42705>, 100);
  295. }
  296. }
  297. state checkParcelOwnerAgain
  298. {
  299. state_entry() {
  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 requestdata;
  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 requestdata
  357. {
  358. state_entry()
  359. {
  360. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  361. body += "&sloodlepwd=" + sloodlepwd;
  362. body += "&sloodlemoduleid=" + (string)sloodlemoduleid;
  363. llSetText("Requesting list of entries...", <0.0, 0.0, 1.0>, 0.8);
  364. httpentries = llHTTPRequest(sloodleserverroot + SLOODLE_SLIDESHOW_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body);
  365. llSetTimerEvent(8.0);
  366. }
  367. state_exit()
  368. {
  369. llSetTimerEvent(0.0);
  370. llSetText("", <0.0, 0.0, 0.0>, 0.0);
  371. }
  372. timer()
  373. {
  374. llSay(0, "Timeout waiting for list of entries");
  375. state error;
  376. }
  377. http_response(key id, integer status, list meta, string body)
  378. {
  379. // Is this the expected data?
  380. if (id != httpentries) return;
  381. httpentries = NULL_KEY;
  382. // Make sure the request worked
  383. if (status != 200) {
  384. sloodle_debug("Failed HTTP response. Status: " + (string)status);
  385. return;
  386. }
  387. // Make sure there is a body to the request
  388. if (llStringLength(body) == 0) return;
  389. // Split the data up into lines
  390. list lines = llParseStringKeepNulls(body, ["\n"], []);
  391. integer numlines = llGetListLength(lines);
  392. // Extract all the status fields
  393. list statusfields = llParseStringKeepNulls( llList2String(lines,0), ["|"], [] );
  394. // Get the statuscode
  395. integer statuscode = llList2Integer(statusfields,0);
  396. // Was it an error code?
  397. if (statuscode <= 0) {
  398. sloodle_error_code(SLOODLE_TRANSLATE_SAY, NULL_KEY,statuscode); //send message to error_message.lsl
  399. string msg = "ERROR: linker script responded with status code " + (string)statuscode;
  400. // Do we have an error message to go with it?
  401. if (numlines > 1) {
  402. msg += "\n" + llList2String(lines,1);
  403. }
  404. sloodle_debug(msg);
  405. return;
  406. }
  407. // Check if we have some more lines
  408. if (llGetListLength(lines) == 1) {
  409. llSay(0, "No images to display.");
  410. state error;
  411. return;
  412. }
  413. // Add each line to our lists of entries
  414. entryurls = [];
  415. entrytypes = [];
  416. entrynames = [];
  417. integer i = 0;
  418. list fields = [];
  419. for (i = 1; i < numlines; i++) {
  420. fields = llParseString2List(llList2String(lines, i), ["|"], []);
  421. if (llGetListLength(fields) >= 2) {
  422. entrytypes += [llList2String(fields, 0)];
  423. entryurls += [llList2String(fields, 1)];
  424. }
  425. }
  426. state running;
  427. }
  428. }
  429. state error
  430. {
  431. state_entry()
  432. {
  433. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT, [<1.0, 0.0, 0.0>, 1.0], "errorstate", [], NULL_KEY, "presenter");
  434. }
  435. state_exit()
  436. {
  437. llSetText("", <0.0, 0.0, 0.0>, 0.0);
  438. }
  439. touch_start(integer num)
  440. {
  441. llResetScript();
  442. }
  443. }
  444. state running
  445. {
  446. state_entry()
  447. {
  448. // Start from the first image
  449. currententry = 0;
  450. sloodle_update_hover_text();
  451. update_image_display();
  452. }
  453. state_exit()
  454. {
  455. llSetText("", <0.0, 0.0, 0.0>, 0.0);
  456. }
  457. touch_start(integer num)
  458. {
  459. if (!sloodle_check_access_ctrl(llDetectedKey(0))){
  460. llSay(0,"Sorry, you are not allowed to control this Presenter.");
  461. return;
  462. }
  463. // Find out what was touched
  464. string buttonname = llGetLinkName(llDetectedLinkNumber(0));
  465. if (buttonname == "next") {
  466. next_image();
  467. } else if (buttonname == "previous") {
  468. previous_image();
  469. } else if (buttonname == "reset") {
  470. currententry = 0;
  471. sloodle_update_hover_text();
  472. update_image_display();
  473. } else if (buttonname == "update") {
  474. requestConfigData=1; // in default data state request config data to ensure
  475. //controller settings proliferate into SL - ie: someone changed the presentation this presenter is pointing to via the web
  476. state initialize;
  477. }
  478. }
  479. changed(integer change) {
  480. if (change ==CHANGED_INVENTORY){
  481. if ((string)llGetInventoryKey(PRESENTER_TEXTURE)=="00000000-0000-0000-0000-000000000000"){
  482. sloodle_translation_request(SLOODLE_TRANSLATE_HOVER_TEXT_BASIC, [<0.92748, 0.00000, 0.42705>, 1.0], "missingsloodletexture", [], NULL_KEY, "presenter");
  483. llSetTimerEvent(3.0);
  484. }
  485. }
  486. }
  487. timer() {
  488. llSetTimerEvent(0.0);
  489. llResetScript();
  490. }
  491. on_rez(integer par) { llResetScript(); }
  492. }
  493. // Please leave the following line intact to show where the script lives in Git:
  494. // SLOODLE LSL Script Git Location: mod/presenter-1.0/objects/default/assets/sloodle_mod_presenter-1.0.lslp