rezzer_reset_btn.lslp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. // LSL script generated: mod.set-1.0.rezzer_reset_btn.lslp Tue Nov 15 15:49:28 Tokyo Standard Time 2011
  4. /*
  5. * Part of the Sloodle project (www.sloodle.org)
  6. *
  7. * Copyright (c) 2011-06 contributors (see below)
  8. * Released under the GNU GPL v3
  9. * -------------------------------------------
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. * All scripts must maintain this copyrite information, including the contributer information listed
  25. *
  26. * Contributors:
  27. * Edmund Edgar
  28. * Paul Preibisch
  29. *
  30. * DESCRIPTION
  31. * This script sits inside of the reset button. When clicked, a countdown is started.
  32. * The countdown can be stopped, by clicking the button again as a toggle.
  33. * If zero is reached by the counter, a linked message is sent to the link_set with a do:reset command
  34. *
  35. */
  36. //reset
  37. //gets a vector from a string
  38. vector RED = <0.77278,4.391e-2,0.0>;
  39. vector YELLOW = <0.82192,0.86066,0.0>;
  40. vector WHITE = <1.0,1.0,1.0>;
  41. float BTN_RESET_OFFSET = 0.25;
  42. float BTN_CANCEL_OFFSET = -0.25;
  43. integer FACE = 4;
  44. integer counter = 0;
  45. integer TIME_LIMIT = 7;
  46. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;
  47. list facilitators;
  48. integer toggle = -1;
  49. default {
  50. on_rez(integer start_param) {
  51. llResetScript();
  52. }
  53. state_entry() {
  54. llSetText("",RED,1.0);
  55. toggle = (-1);
  56. llSetTexture("btn_reset_cancel",FACE);
  57. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  58. llRotateTexture(-90*DEG_TO_RAD, ALL_SIDES);
  59. llSetObjectName("btn:Reset");
  60. facilitators += llStringTrim(llToLower(llKey2Name(llGetOwner())),STRING_TRIM);
  61. }
  62. touch_start(integer d) {
  63. integer j;
  64. for (j=0;j<d;j++){
  65. if (llDetectedKey(j)!=llGetOwner()){
  66. llSay(0,"Sorry, only "+llKey2Name(llGetOwner())+" can reset this device.");
  67. return;
  68. }
  69. llTriggerSound("click",1.0);
  70. if ((toggle == (-1))) {
  71. toggle *= (-1);
  72. llSetColor(YELLOW,FACE);
  73. llOffsetTexture(0,BTN_CANCEL_OFFSET,FACE);
  74. llSetObjectName("btn:Cancel");
  75. llSetTimerEvent(1);
  76. }
  77. else {
  78. toggle *= (-1);
  79. llSetColor(WHITE,FACE);
  80. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  81. llSetText("",RED,1.0);
  82. llSetTimerEvent(0);
  83. llSetObjectName("btn:Reset");
  84. counter = 0;
  85. }
  86. llRotateTexture(-90*DEG_TO_RAD, ALL_SIDES);
  87. }
  88. }
  89. timer() {
  90. counter++;
  91. vector color;
  92. if ((llGetColor(FACE) == YELLOW)) {
  93. color = RED;
  94. } else {
  95. color = YELLOW;
  96. }
  97. llSetText((("(" + ((string)(TIME_LIMIT - counter))) + ")"),color,1.0);
  98. llSetColor(color,FACE);
  99. if ((counter >= TIME_LIMIT)) {
  100. llSetTimerEvent(0.0);
  101. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  102. llRotateTexture(-90*DEG_TO_RAD, ALL_SIDES);
  103. llSetObjectName("btn:Reset");
  104. toggle *= (-1);
  105. llSetText("",RED,1.0);
  106. llSetColor(WHITE,FACE);
  107. llMessageLinked(LINK_SET,SLOODLE_CHANNEL_OBJECT_DIALOG,"do:reset",NULL_KEY);
  108. counter = 0;
  109. }
  110. else llTriggerSound("beepbeep",0.2);
  111. }
  112. changed(integer change) {
  113. if ((change == CHANGED_INVENTORY)) {
  114. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  115. llRotateTexture(-90*DEG_TO_RAD, ALL_SIDES);
  116. llSetObjectName("btn:Reset");
  117. llResetScript();
  118. }
  119. }
  120. }
  121. // Please leave the following line intact to show where the script lives in Git:
  122. // SLOODLE LSL Script Git Location: mod/set-1.0/objects/default/assets/rezzer_reset_btn.lslp