presentation_seating.lslp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * presentation_seating
  3. * Part of the Sloodle project (www.sloodle.org)
  4. *
  5. * Copyright (c) 2011-06 contributors (see below)
  6. * Released under the GNU GPL v3
  7. * -------------------------------------------
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * All scripts must maintain this copyright information, including the contributer information listed
  23. *
  24. * DESCRIPTION
  25. * This script should be placed in each chair, it listens to the SLOODLE_CHANNEL_OBJECT_DIALOG channel for set:color
  26. *
  27. * Contributors:
  28. * Paul Preibisch
  29. * Edmund Edgar
  30. */
  31. string SLOODLE_EOF = "sloodleeof";
  32. integer eof= FALSE;
  33. integer isconfigured=FALSE;
  34. 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.
  35. vector color= <0,0,0>;
  36. integer sloodle_handle_command(string str)
  37. {
  38. list bits = llParseString2List(str,["|"],[]);
  39. integer numbits = llGetListLength(bits);
  40. string name = llList2String(bits,0);
  41. string value1 = "";
  42. string value2 = "";
  43. if (numbits > 1) value1 = llList2String(bits,1);
  44. if (numbits > 2) value2 = llList2String(bits,2);
  45. if (name == "set:color"){
  46. color = (vector)value1;
  47. llSetColor(color,ALL_SIDES);
  48. }
  49. else if (name == SLOODLE_EOF) eof = TRUE;
  50. return (color != ZERO_VECTOR);
  51. }
  52. default {
  53. on_rez(integer start_param) {
  54. llResetScript();
  55. }
  56. state_entry() {
  57. }
  58. link_message( integer sender_num, integer num, string str, key id)
  59. {
  60. // Check the channel
  61. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  62. // Split the message into lines
  63. list lines = llParseString2List(str, ["\n"], []);
  64. integer numlines = llGetListLength(lines);
  65. integer i = 0;
  66. for (; i < numlines; i++) {
  67. isconfigured = sloodle_handle_command(llList2String(lines, i));
  68. }
  69. // If we've got all our data AND reached the end of the configuration data, then move on
  70. if (eof == TRUE) {
  71. if (isconfigured == TRUE) {
  72. //sloodle_translation_request(SLOODLE_TRANSLATE_SAY, [0], "configurationreceived", [], null_key, "");
  73. state ready;
  74. }
  75. }
  76. }
  77. }
  78. }
  79. state ready{
  80. link_message( integer sender_num, integer num, string str, key id)
  81. {
  82. // Check the channel
  83. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  84. // Split the message into lines
  85. list lines = llParseString2List(str, ["\n"], []);
  86. integer numlines = llGetListLength(lines);
  87. integer i = 0;
  88. for (; i < numlines; i++) {
  89. isconfigured = sloodle_handle_command(llList2String(lines, i));
  90. }
  91. }
  92. }
  93. on_rez(integer start_param) {
  94. llResetScript();
  95. }
  96. }
  97. // Please leave the following line intact to show where the script lives in Git:
  98. // SLOODLE LSL Script Git Location: mod/furniture-1.0/objects/default/assets/presentation_seating.lslp