blinker.lslp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. * blinker.lslp
  7. *
  8. * Copyright (c) 2011-06 contributors (see below)
  9. * Released under the GNU GPL v3
  10. * -------------------------------------------
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. * All scripts must maintain this copyrite information, including the contributer information listed
  26. *
  27. * Contributors:
  28. * Paul Preibisch
  29. *
  30. * DESCRIPTION
  31. * This script can be used to set the texture or make a linked prim blink.
  32. * Drop this script into a linked prim then send one of the following commands:
  33. *
  34. * To set the texture:
  35. * (linked prim name) (face) (texture name)
  36. * eg: llMessageLinked(LINK_SET, SLOODLE_SET_TEXTURE, "pie_slice"+(string)j+"|"+(string)face+"|"+texture,NULL_KEY);
  37. *
  38. * If developer wants a prim to blink, you can send it two colors which it will toggle between every second for x seconds (timer) and then change back to default color
  39. * (linked prim name) (face) (color1) (color2) (default color) (timer)
  40. * llMessageLinked(LINK_SET, SLOODLE_BLINKER, "blinker_prim|"+(string)ALL_SIDES+"|"+(string)BABY_BLUE+"|"+(string)BLUE+"|"+(string)REZZER_GREY+"|3", NULL_KEY);
  41. *
  42. * Using this instead of llSetPrimitiveParamsFast because doesn't appear to work in opensim
  43. */
  44. integer SLOODLE_SET_TEXTURE= -1639277010;
  45. integer SLOODLE_BLINKER=1639277019;//used to send commands to a prim which should blink
  46. vector YELLOW=<1.00000, 1.00000, 0.00000>;
  47. init(){
  48. llSetTexture("blank_white", ALL_SIDES);
  49. }
  50. integer count=0;
  51. integer TIME_LIMIT=0;
  52. vector TOGGLE_COLOR_1;
  53. vector TOGGLE_COLOR_2;
  54. vector DEFAULT_COLOR;
  55. string MESSAGE;
  56. default {
  57. on_rez(integer start_param) {
  58. init();
  59. }
  60. state_entry() {
  61. init();
  62. }
  63. link_message(integer sender_num, integer num, string str, key id) {
  64. if (num==SLOODLE_SET_TEXTURE){
  65. list data = llParseString2List(str, ["|"], []);
  66. string prim=llList2String(data, 0);
  67. if (prim!=llGetObjectName()){
  68. return;
  69. }
  70. integer face=llList2Integer(data, 1);
  71. string texture=llList2String(data, 2);
  72. llSetTexture(texture, face);
  73. }
  74. else
  75. if (num==SLOODLE_BLINKER){
  76. //"blinker_prim|"+(string)ALL_SIDES+"|"+(string)BABYBLUE+"|"+(string)BLUE+"|"+(string)REZZER_GREY+"|3|Received Message from the Server", NULL_KEY);
  77. list data = llParseString2List(str, ["|"], []);
  78. string prim=llList2String(data, 0);
  79. integer face=llList2Integer(data, 1);
  80. vector TOGGLE_COLOR_1=llList2Vector(data, 2);
  81. vector TOGGLE_COLOR_2=llList2Vector(data, 3);
  82. vector DEFAULT_COLOR=llList2Vector(data, 4);
  83. TIME_LIMIT= llList2Integer(data,5);
  84. MESSAGE= llList2String(data,6);
  85. if (prim!=llGetObjectName()){
  86. return;
  87. }
  88. count=0;
  89. llSetColor(TOGGLE_COLOR_1, face);
  90. llSetText(MESSAGE, YELLOW, 1);
  91. llSetTimerEvent(1);
  92. }
  93. }
  94. timer() {
  95. count++;
  96. if (count<=TIME_LIMIT){
  97. if (count%2==0){
  98. llSetColor(TOGGLE_COLOR_1, ALL_SIDES);
  99. }else{
  100. llSetColor(TOGGLE_COLOR_2, ALL_SIDES);
  101. }
  102. }else{
  103. llSetTimerEvent(0);
  104. llSetColor(DEFAULT_COLOR, ALL_SIDES);
  105. count=0;
  106. llSetText("", YELLOW, 1);
  107. }
  108. }
  109. }