skeleton_function.lslp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. /*
  4. * Part of the Sloodle project (www.sloodle.org)
  5. *
  6. * Copyright (c) 2011-06 contributors (see below)
  7. * Released under the GNU GPL v3
  8. * -------------------------------------------
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * All scripts must maintain this copyrite information, including the contributer information listed
  24. *
  25. * Contributors:
  26. * Paul Preibisch
  27. * Edmund Edgar
  28. *
  29. * DESCRIPTION
  30. *
  31. */
  32. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343; // an arbitrary channel the sloodle scripts will use to talk to each other. Doesn't atter what it is, as long as the same thing is set in the sloodle_slave script.
  33. string sloodleserverroot = "";
  34. integer sloodlecontrollerid = 0;
  35. string sloodlepwd = "";
  36. integer sloodlemoduleid = 0;
  37. integer sloodleobjectaccessleveluse = 0; // Who can use this object?
  38. integer sloodleobjectaccesslevelctrl = 0; // Who can control this object?
  39. integer sloodleserveraccesslevel = 0; // Who can use the server resource? (Value passed straight back to Moodle)
  40. integer isconfigured = FALSE; // Do we have all the configuration data we need?
  41. string SLOODLE_EOF = "sloodleeof";
  42. integer eof = FALSE; // Have we reached the end of the configuration data?
  43. integer SLOODLE_CHANNEL_QUIZ_MASTER_REQUEST= -1639277006;
  44. integer SLOODLE_CHANNEL_USER_TOUCH = -1639277002;//user touched object
  45. integer SLOODLE_CHANNEL_QUIZ_MASTER_RESPONSE= -1639277008;
  46. integer SLOODLE_CHANNEL_QUIZ_LOADING_QUIZ = -1639271109;
  47. integer SLOODLE_CHANNEL_TRANSLATION_REQUEST = -1928374651;
  48. integer SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST=-1828374651;
  49. string SLOODLE_TRANSLATE_HOVER_TEXT = "hovertext"; // 2 output parameters: colour <r,g,b>, and alpha value
  50. string SLOODLE_TRANSLATE_WHISPER = "whisper"; // 1 output parameter: chat channel number
  51. string SLOODLE_TRANSLATE_SAY = "say"; // 1 output parameter: chat channel number
  52. string SLOODLE_TRANSLATE_OWNER_SAY = "ownersay"; // No output parameters
  53. 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.
  54. string SLOODLE_TRANSLATE_LOAD_URL = "loadurl"; // Recipient avatar should be identified in link message keyval. 1 output parameter giving URL to load.
  55. string SLOODLE_TRANSLATE_IM = "instantmessage"; // Recipient avatar should be identified in link message keyval. No output parameters.
  56. integer SLOODLE_OBJECT_ACCESS_LEVEL_PUBLIC = 0;
  57. integer SLOODLE_OBJECT_ACCESS_LEVEL_OWNER = 1;
  58. integer SLOODLE_OBJECT_ACCESS_LEVEL_GROUP = 2;
  59. vector RED =<1.00000, 0.00000, 0.00000>;
  60. vector ORANGE=<1.00000, 0.43763, 0.02414>;
  61. vector YELLOW=<1.00000, 1.00000, 0.00000>;
  62. vector GREEN=<0.00000, 1.00000, 0.00000>;
  63. vector BLUE=<0.00000, 0.00000, 1.00000>;
  64. vector BABYBLUE=<0.00000, 1.00000, 1.00000>;
  65. vector PINK=<1.00000, 0.00000, 1.00000>;
  66. vector PURPLE=<0.57338, 0.25486, 1.00000>;
  67. vector BLACK= <0.00000, 0.00000, 0.00000>;
  68. vector WHITE= <1.00000, 1.00000, 1.00000>;
  69. vector AVCLASSBLUE= <0.06274,0.247058,0.35294>;
  70. vector AVCLASSLIGHTBLUG=<0.8549,0.9372,0.9686>;//#daeff7
  71. sloodle_error_code(string method, key avuuid,integer statuscode, string msg){
  72. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_ERROR_TRANSLATION_REQUEST, method+"|"+(string)avuuid+"|"+(string)statuscode+"|"+(string)msg, NULL_KEY);
  73. }
  74. sloodle_debug(string msg){
  75. llMessageLinked(LINK_THIS, DEBUG_CHANNEL, msg, NULL_KEY);
  76. }
  77. // Send a translation request link message
  78. sloodle_translation_request(string output_method, list output_params, string string_name, list string_params, key keyval, string batch){
  79. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_TRANSLATION_REQUEST, output_method + "|" + llList2CSV(output_params) + "|" + string_name + "|" + llList2CSV(string_params) + "|" + batch, keyval);
  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. list bits = llParseString2List(str,["|"],[]);
  85. integer numbits = llGetListLength(bits);
  86. string name = llList2String(bits,0);
  87. string value1 = "";
  88. string value2 = "";
  89. if (numbits > 1) value1 = llList2String(bits,1);
  90. if (numbits > 2) value2 = llList2String(bits,2);
  91. if (name == "set:sloodleserverroot") sloodleserverroot = value1;
  92. else if (name == "set:sloodlepwd") {
  93. // The password may be a single prim password, or a UUID and a password
  94. if (value2 != "") {
  95. sloodlepwd = value1 + "|" + value2;
  96. }
  97. else {
  98. sloodlepwd = value1;
  99. }
  100. }
  101. else if (name == "set:sloodlecontrollerid") sloodlecontrollerid = (integer)value1;
  102. else if (name == "set:sloodlemoduleid") sloodlemoduleid = (integer)value1;
  103. else if (name == "set:sloodleobjectaccessleveluse") sloodleobjectaccessleveluse = (integer)value1;
  104. else if (name == "set:sloodleserveraccesslevel") sloodleserveraccesslevel = (integer)value1;
  105. else if (name == SLOODLE_EOF) eof = TRUE;
  106. return (sloodleserverroot != "" && sloodlepwd != "" && sloodlecontrollerid > 0 && sloodlemoduleid > 0);
  107. }
  108. debug (string message ){
  109. list params = llGetPrimitiveParams ([PRIM_MATERIAL ]);
  110. if (llList2Integer (params ,0)==PRIM_MATERIAL_FLESH){
  111. llOwnerSay("memory: "+(string)llGetFreeMemory()+" Script name: "+llGetScriptName ()+": " +message );
  112. }
  113. }
  114. default {
  115. on_rez(integer start_param) {
  116. llResetScript();
  117. }
  118. state_entry(){
  119. isconfigured = FALSE;
  120. eof = FALSE;
  121. }
  122. link_message( integer sender_num, integer chan, string str, key user_key){
  123. // Check the channel for configuration messages
  124. if (chan == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  125. // Split the message into lines
  126. list lines = llParseString2List(str, ["\n"], []);
  127. integer numlines = llGetListLength(lines);
  128. integer i = 0;
  129. for (i=0; i < numlines; i++) {
  130. isconfigured = sloodle_handle_command(llList2String(lines, i));
  131. }
  132. // If we've got all our data AND reached the end of the configuration data (eof), then move on
  133. if (eof == TRUE) {
  134. if (isconfigured == TRUE) {
  135. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configurationreceived", [], NULL_KEY, "");
  136. state ready;
  137. } else {
  138. // Go all configuration but, it's not complete... request reconfiguration
  139. sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configdatamissing", [llGetScriptName()], NULL_KEY, "");
  140. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_DIALOG, "do:reconfigure", NULL_KEY);
  141. eof = FALSE;
  142. }
  143. }
  144. }
  145. }
  146. }
  147. state ready{
  148. on_rez(integer start_param) {
  149. llResetScript();
  150. }
  151. state_entry() {
  152. }
  153. touch_start(integer n) {
  154. }
  155. link_message(integer sender_num, integer chan, string str, key id) {
  156. }
  157. }