sloodle_reset_button.lslp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. llSetObjectName("btn:Reset");
  59. facilitators += llStringTrim(llToLower(llKey2Name(llGetOwner())),STRING_TRIM);
  60. }
  61. touch_start(integer d) {
  62. integer j;
  63. for (j=0;j<d;j++){
  64. if (llDetectedKey(j)!=llGetOwner()){
  65. llSay(0,"Sorry, only "+llKey2Name(llGetOwner())+" can reset this device.");
  66. return;
  67. }
  68. llTriggerSound("click",1.0);
  69. if ((toggle == (-1))) {
  70. toggle *= (-1);
  71. llSetColor(YELLOW,FACE);
  72. llOffsetTexture(0,BTN_CANCEL_OFFSET,FACE);
  73. llSetObjectName("btn:Cancel");
  74. llSetTimerEvent(1);
  75. }
  76. else {
  77. toggle *= (-1);
  78. llSetColor(WHITE,FACE);
  79. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  80. llSetText("",RED,1.0);
  81. llSetTimerEvent(0);
  82. llSetObjectName("btn:Reset");
  83. counter = 0;
  84. }
  85. }
  86. }
  87. timer() {
  88. counter++;
  89. vector color;
  90. if ((llGetColor(FACE) == YELLOW)) {
  91. color = RED;
  92. } else {
  93. color = YELLOW;
  94. }
  95. llSetText((("(" + ((string)(TIME_LIMIT - counter))) + ")"),color,1.0);
  96. llSetColor(color,FACE);
  97. if ((counter >= TIME_LIMIT)) {
  98. llSetTimerEvent(0.0);
  99. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  100. llSetObjectName("btn:Reset");
  101. toggle *= (-1);
  102. llSetText("",RED,1.0);
  103. llSetColor(WHITE,FACE);
  104. llMessageLinked(LINK_SET,SLOODLE_CHANNEL_OBJECT_DIALOG,"do:reset",NULL_KEY);
  105. counter = 0;
  106. }
  107. else llTriggerSound("beepbeep",0.2);
  108. }
  109. changed(integer change) {
  110. if ((change == CHANGED_INVENTORY)) {
  111. llOffsetTexture(0,BTN_RESET_OFFSET,FACE);
  112. llSetObjectName("btn:Reset");
  113. llResetScript();
  114. }
  115. }
  116. }
  117. // Please leave the following line intact to show where the script lives in Git:
  118. // SLOODLE LSL Script Git Location: mod/set-1.0/objects/default/assets/rezzer_reset_btn.lslp