GetLessonPages.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <!-- headlinks removed -->
  6. <link rel="shortcut icon" href="../../../../misc/favicon.ico"/>
  7. <title>GetLessonPages - SLIS Second Life Wiki</title>
  8. <style type="text/css">/*<![CDATA[*/ @import "../../../../skins/offline/main.css"; /*]]>*/</style>
  9. <link rel="stylesheet" type="text/css" media="print" href="../../../../skins/common/commonPrint.css" />
  10. <!--[if lt IE 5.5000]><style type="text/css">@import "../../../../skins/monobook/IE50Fixes.css";</style><![endif]-->
  11. <!--[if IE 5.5000]><style type="text/css">@import "../../../../skins/monobook/IE55Fixes.css";</style><![endif]-->
  12. <!--[if IE 6]><style type="text/css">@import "../../../../skins/monobook/IE60Fixes.css";</style><![endif]-->
  13. <!--[if IE]><script type="text/javascript" src="../../../../skins/common/IEFixes.js"></script>
  14. <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
  15. <script type="text/javascript" src="../../../../skins/common/wikibits.js"></script>
  16. <script type="text/javascript" src="../../../../skins/offline/md5.js"></script>
  17. <script type="text/javascript" src="../../../../skins/offline/utf8.js"></script>
  18. <script type="text/javascript" src="../../../../skins/offline/lookup.js"></script>
  19. </head>
  20. <body
  21. class="ns-0 ns-subject page-GetLessonPages">
  22. <div id="globalWrapper">
  23. <div id="column-content">
  24. <div id="content">
  25. <a name="top" id="contentTop"></a>
  26. <h1 class="firstHeading">GetLessonPages</h1>
  27. <div id="bodyContent">
  28. <h3 id="siteSub">From SLIS Second Life Wiki</h3>
  29. <div id="contentSub"></div>
  30. <!-- start content -->
  31. <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><table border="0" cellpadding="0" cellspacing="0" style="text-align: top; width: 95%;">
  32. <tr>
  33. <td> <a href="../../../../articles/s/l/o/SLOODLE_LSL_API.html" title="SLOODLE LSL API">Back to Sloodle API</a>
  34. </td></tr></table>
  35. <p><br />
  36. </p>
  37. <table border="2" cellpadding="0" cellspacing="0" style="text-align: top; width: 95%; color:#5a3696; border-color:black;">
  38. <tr>
  39. <td>
  40. <table border="0" style="width: 100%; background:#f4f8fb; color:#5a3696; font-weight:bold; font-size:180%;">
  41. <tr>
  42. <td>Function: getLessonPages
  43. </td></tr></table>
  44. </td></tr>
  45. <tr>
  46. <td>
  47. <table border="0">
  48. <tr>
  49. <td style="width: 10%; font-weight:bold;"> Description:
  50. </td>
  51. <td style="width: 90%;"> Returns a list of lesson pages for the lesson specified along with page data
  52. </td></tr></table>
  53. </td></tr>
  54. <tr>
  55. <td>
  56. <table border="0">
  57. <tr>
  58. <td style="width: 10%; font-weight:bold;"> <font color="red">llMessageLinked</font>(<font color="green">LINK_SET</font>, PLUGIN_CHANNEL, "<font color="green">plugin:lessons,function:getLessonPages\nSLOODLEID:null\nindex:0|lessonsPerPage:9|lessonid:1</font>", <font color="red">NULL_KEY</font>);
  59. </td></tr></table>
  60. </td></tr>
  61. <tr>
  62. <td>
  63. <table border="0">
  64. <tr>
  65. <td style="width: 10%; font-weight:bold;" colspan="2"> Parameters:
  66. </td></tr>
  67. <tr>
  68. <td style="width: 10%; color:green;"> <b>SLOODLE_ID:null</b>
  69. </td>
  70. <td style="width: 90%;"> this is left as null because we aren't accessing a specific activity
  71. </td></tr>
  72. <tr>
  73. <td style="width: 10%; color:green;"> <b>INDEX</b>:
  74. </td>
  75. <td style="width: 90%;"> The index of the lesson page you'd like to start from
  76. </td></tr>
  77. <tr>
  78. <td style="width: 10%; color:green;"> <b>ITEMS_PER_PAGE</b>:
  79. </td>
  80. <td style="width: 90%;"> The number of items you'd like to appear in the output
  81. </td></tr>
  82. <tr>
  83. <td style="width: 10%; color:green;"> <b>LESSON ID</b>:
  84. </td>
  85. <td style="width: 90%;"> The id of lesson you want pages from
  86. </td></tr></table>
  87. <p><br />
  88. </p>
  89. </td></tr>
  90. <tr>
  91. <td>
  92. <table border="0">
  93. <tr>
  94. <td style="width: 10%; font-weight:bold;"> Output:
  95. </td>
  96. <td style="width: 90%;"> <a href="../../../../articles/g/e/t/File:GetlessonPages.jpg.html" class="image"><img alt="GetlessonPages.jpg" src="../../../../images/0/2F/0/0/09/GetlessonPages.jpg" width="610" height="193" /></a>
  97. </td></tr></table>
  98. <p><br />
  99. </p>
  100. </td></tr>
  101. <tr>
  102. <td>
  103. <table border="0">
  104. <tr>
  105. <td style="width: 10%; font-weight:bold;"> Example Script:
  106. </td>
  107. <td style="width: 90%;">
  108. <pre> /*********************************************
  109. * Copyright (c) 2009 Paul Preibisch
  110. * Released under the GNU GPL 3.0
  111. * This script can be used in your scripts, but you must include this copyright header as per the GPL Licence
  112. * For more information about GPL 3.0 - see: <a rel="nofollow" class="external free" href="http://www.gnu.org/copyleft/gpl.html">http://www.gnu.org/copyleft/gpl.html</a>
  113. *
  114. *
  115. * This script is part of the SLOODLE Project see <a rel="nofollow" class="external free" href="http://sloodle.org">http://sloodle.org</a>
  116. *
  117. * Copyright:
  118. * Paul G. Preibisch (Fire Centaur in SL)
  119. * fire@b3dMultiTech.com
  120. *
  121. * API DEMO OBJECT
  122. * getLessonPages.lsl
  123. *
  124. * PURPOSE
  125. * This script is part of the SLOODLE HQ.
  126. *
  127. /**********************************************************************************************/
  128. key owner;
  129. // *************************************************** HOVER TEXT VARIABLES
  130. integer DISPLAY_DATA =-774477; //every time the display is updated, data goes on this channel
  131. integer PLUGIN_RESPONSE_CHANNEL =998822; //sloodle_api.lsl responses
  132. integer PLUGIN_CHANNEL =998821;//sloodle_api requests
  133. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;//translation channel
  134. integer SLOODLE_CHANNEL_TRANSLATION_RESPONSE = -1928374652;//translation channel
  135. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;//configuration channel
  136. /***********************************************
  137. * getFieldData-- returns data from a table based on the column name
  138. ***********************************************/
  139. string getFieldData(list tableRowData, string colName){
  140. return llList2String(tableRowData,llListFindList(tableRowData, [colName])+1);
  141. }
  142. /***********************************************
  143. * s() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  144. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  145. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  146. * All this function does is strip off the text before the ":" char and return a string
  147. ***********************************************/
  148. string s (string ss){
  149. return llList2String(llParseString2List(ss, [":"], []),1);
  150. }
  151. /***********************************************
  152. * k() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  153. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  154. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  155. * All this function does is strip off the text before the ":" char and return a key
  156. ***********************************************/
  157. key k (string kk){
  158. return llList2Key(llParseString2List(kk, [":"], []),1);
  159. }
  160. /***********************************************
  161. * counter() used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  162. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  163. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  164. * All this function does is strip off the text before the ":" char and return an integer
  165. ***********************************************/
  166. integer i (string ii){
  167. return llList2Integer(llParseString2List(ii, [":"], []),1);
  168. }
  169. /* &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
  170. *
  171. * default state
  172. * In this state we wait until the rest of the scripts in this object init
  173. *
  174. * &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; */
  175. default{
  176. state_entry() {
  177. //set owner
  178. owner = llGetOwner();
  179. }
  180. link_message(integer sender_num, integer channel, string str, key id) {
  181. list dataLines=llParseString2List(str, ["\n"],[]);
  182. list cmdLine = llParseString2List(str, ["|"],[]);
  183. string cmd=s(llList2String(cmdLine,0));
  184. if (channel==PLUGIN_RESPONSE_CHANNEL){
  185. if (cmd=="API READY") state go;
  186. }//endif channel=PLUGIN_RESPONSE_CHANNEL
  187. }//end linked_message event
  188. /***********************************************
  189. * changed event
  190. * |--&gt;Every time the inventory changes, reset the script
  191. *
  192. ***********************************************/
  193. changed(integer change) {
  194. if (change ==CHANGED_INVENTORY){
  195. llResetScript();
  196. }//endif
  197. }//end changed state
  198. }//end default state
  199. /* &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;
  200. *
  201. * go state
  202. * Now you can execute your logic because the api is ready
  203. *
  204. * &amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp; */
  205. state go{
  206. touch_start(integer num_detected) {
  207. /*********************************************************************************
  208. * API CALL: getLessons: Return all lesson pages in the course
  209. **********************************************************************************/
  210. llMessageLinked(LINK_SET, PLUGIN_CHANNEL, "plugin:lessons,function:getLessonPages\nSLOODLEID:null\nindex:0|lessonsPerPage:9|lessonid:1", NULL_KEY);
  211. }
  212. link_message(integer sender_num, integer channel, string str, key id) {
  213. if (channel==PLUGIN_RESPONSE_CHANNEL){
  214. list dataLines = llParseStringKeepNulls(str,["\n"],[]);
  215. //get status code
  216. list statusLine =llParseString2List(llList2String(dataLines,0),["|"],[]);
  217. integer status =llList2Integer(statusLine,0);
  218. string descripter = llList2String(statusLine,1);
  219. string response = s(llList2String(dataLines,1));
  220. integer index = i(llList2String(dataLines,2));
  221. integer counter=0;
  222. if (response=="lessons|getLessonPages"){
  223. //check status of returned response
  224. if (status==1){
  225. //initialize the string we will print on xy_text channel
  226. //get all of the lesson activities returned
  227. list lessons = llList2List(dataLines, 5,llGetListLength(dataLines)-1);
  228. integer len = llGetListLength(lessons);
  229. list colNames =llParseString2List(llList2String(dataLines,4), ["|"], []);
  230. integer colLen = llGetListLength(colNames);
  231. list data;
  232. for (counter=0;counter&lt;len;counter++){
  233. list colData=llParseString2List(llList2String(lessons,counter), ["|"], []); //parse the message into a list
  234. integer j;
  235. //add all data from this line into a 2 dimensional list called tableRowData:
  236. //["nameOfColumn","value"]
  237. list tableRowData;
  238. for (j=0;j&lt;colLen;j++){
  239. tableRowData +=[llList2String(colNames,j),llList2String(colData,j)];
  240. llOwnerSay("// "+(string)(j+1)+") "+llList2String(colNames,j)+": "+llList2String(colData,j));
  241. }
  242. llOwnerSay("//********************************");
  243. }//for
  244. }//status==1
  245. }//endif response=="getLessons"
  246. }//end if channel==PLUGIN_RESPONSE_CHANNEL
  247. }//end link_message
  248. /***********************************************
  249. * changed event
  250. * |--&gt;Every time the inventory changes, reset the script
  251. *
  252. ***********************************************/
  253. changed(integer change) {
  254. if (change ==CHANGED_INVENTORY){
  255. llResetScript();
  256. }//endif
  257. }//end changed state
  258. }//end state
  259. </pre>
  260. <p><br />
  261. </p><p><br />
  262. </p><p><br />
  263. </p>
  264. </td></tr></table>
  265. <p><br />
  266. </p>
  267. </td></tr></table>
  268. <!--
  269. NewPP limit report
  270. Preprocessor node count: 5/1000000
  271. Post‐expand include size: 0/2097152 bytes
  272. Template argument size: 0/2097152 bytes
  273. Expensive parser function count: 0/100
  274. -->
  275. </div><div class="printfooter">
  276. </div>
  277. <div id="catlinks"><div id='catlinks' class='catlinks'><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="http://localhost/sl/index.php/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="../../../../articles/i/n/w/Category:Inworld_API.html" title="Category:Inworld API">Inworld API</a></li></ul></div></div></div> <!-- end content -->
  278. <div class="visualClear"></div>
  279. </div>
  280. </div>
  281. </div>
  282. <div id="column-one">
  283. <div id="p-cactions" class="portlet">
  284. <h5>Views</h5>
  285. <ul>
  286. <li id="ca-nstab-main"
  287. class="selected" ><a href="../../../../articles/g/e/t/GetLessonPages.html">Page</a></li><li id="ca-talk"
  288. class="new" ><a href="http:http://localhost/sl/index.php?title=Talk:GetLessonPages&amp;action=edit&amp;redlink=1">Discussion</a></li><li id="ca-current"
  289. ><a href="http://localhost/sl/index.php/GetLessonPages">Latest revision</a></li> </ul>
  290. </div>
  291. <div class="portlet" id="p-logo">
  292. <a style="background-image: url(../../../../misc/wiki.png);"
  293. href="../../../../index.html"
  294. title="Main Page"></a>
  295. </div>
  296. <script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
  297. <div class='portlet' id='p-navigation'>
  298. <h5>Navigation</h5>
  299. <div class='pBody'>
  300. <ul>
  301. <li id="n-mainpage-description"><a href="../../../../index.html">Main page</a></li>
  302. <li id="n-SLOODLE"><a href="../../../../articles/s/l/o/Sloodle.html">SLOODLE</a></li>
  303. <li id="n-currentevents"><a href="../../../../articles/c/u/r/SLIS_Second_Life_Wiki:Current_events.html">Current events</a></li>
  304. <li id="n-help"><a href="../../../../articles/c/o/n/Help:Contents.html">Help</a></li>
  305. </ul>
  306. </div>
  307. </div>
  308. <div class='portlet' id='p-SEARCH'>
  309. <h5>Search</h5>
  310. <div class='pBody'>
  311. <ul>
  312. </ul>
  313. </div>
  314. </div>
  315. <div class='portlet' id='p-TOOLBOX'>
  316. <h5>Toolbox</h5>
  317. <div class='pBody'>
  318. <ul>
  319. </ul>
  320. </div>
  321. </div>
  322. <div class='portlet' id='p-LANGUAGES'>
  323. <h5>LANGUAGES</h5>
  324. <div class='pBody'>
  325. <ul>
  326. </ul>
  327. </div>
  328. </div>
  329. <div id="p-search" class="portlet">
  330. <h5><label for="searchInput">Search</label></h5>
  331. <div id="searchBody" class="pBody">
  332. <form action="javascript:goToStatic(3)" id="searchform"><div>
  333. <input id="searchInput" name="search" type="text"
  334. accesskey="f" value="" />
  335. <input type='submit' name="go" class="searchButton" id="searchGoButton"
  336. value="Go" />
  337. </div></form>
  338. </div>
  339. </div>
  340. </div><!-- end of the left (by default at least) column -->
  341. <div class="visualClear"></div>
  342. <div id="footer">
  343. <div id="f-poweredbyico"><a href="//www.mediawiki.org/"><img src="../../../../skins/common/images/poweredby_mediawiki_88x31.png" height="31" width="88" alt="Powered by MediaWiki" /></a></div> <ul id="f-list">
  344. <li id="f-credits">This page was last modified 09:11, 12 October 2009 by <a href="http:http://localhost/sl/index.php?title=User:Salahzar&amp;action=edit&amp;redlink=1" class="new" title="User:Salahzar (page does not exist)">salahzar</a>. Based on work by <a href="../../../../articles/d/a/n/User:Daniel.html" title="User:Daniel">daniel.livingstone@gmail.com</a> and <a href="http:http://localhost/sl/index.php?title=User:Fire&amp;action=edit&amp;redlink=1" class="new" title="User:Fire (page does not exist)">Paul Preibisch</a>.</li> <li id="f-about"><a href="../../../../articles/a/b/o/SLIS_Second_Life_Wiki:About.html" title="SLIS Second Life Wiki:About">About SLIS Second Life Wiki</a></li> <li id="f-disclaimer"><a href="../../../../articles/g/e/n/SLIS_Second_Life_Wiki:General_disclaimer.html" title="SLIS Second Life Wiki:General disclaimer">Disclaimers</a></li> </ul>
  345. </div>
  346. </div>
  347. </body>
  348. </html>