Shins Script.lsl 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. //HYPERGRID STORY NINE
  2. // List NPC Listener channels
  3. //sara=11 sammy=12 claire=13 jolinda=14 tiny=15 tiny2=16 fireworks=20
  4. integer gListener; // Listener for handling different channels
  5. integer gSimpleMenuChannel; // The channel used for the menu
  6. float gTimerInterval = 1; // Keep this at 1 for your sanity.
  7. list gTimeoutList;
  8. float gTimeElapsed=0;
  9. integer gAutofire=FALSE;
  10. //============================================================================
  11. vector gFacecolor=<1.0,0.0,0.0>; //RED
  12. integer gNewTime;
  13. integer gOldTime;
  14. //==Function that returns a random number for our menu handler channel
  15. integer randomchannel() {
  16. return((integer)(llFrand(99999.0)*-1));
  17. }
  18. menu(key id, integer channel, string title, list buttons) {
  19. llListenRemove(gListener);
  20. gListener = llListen(channel,"",id,"");
  21. llDialog(id,title,buttons,channel);
  22. // TimerEvent for killing the menu listener
  23. settimeout("untouched", 30); //call untouched timeout
  24. }
  25. simplemenu(key id) {
  26. gSimpleMenuChannel = randomchannel();
  27. menu(id,gSimpleMenuChannel,"Select an option",["FIREWORKS","SARA","SAMMY","CLAIRE","JOLINDA","TINY","TINY2","LeadNPC","Finale!","CeaseFire"]);
  28. }
  29. settimeout(string timereventid, float time) {
  30. if(gTimeoutList == [])
  31. llSetTimerEvent(gTimerInterval);
  32. integer identifyerIndex = llListFindList(gTimeoutList, [timereventid]);
  33. if (identifyerIndex != -1)
  34. gTimeoutList = llDeleteSubList(gTimeoutList, identifyerIndex - 1, identifyerIndex);
  35. if (time != 0) {
  36. gTimeoutList += time + gTimeElapsed;
  37. gTimeoutList += timereventid;
  38. }
  39. gTimeoutList = llListSort(gTimeoutList, 2, TRUE);
  40. }
  41. timeout(string timereventid)
  42. {
  43. if (timereventid == "untouched")
  44. {
  45. llSay(0, "I have been untouched for 30 seconds, killing menu listener!");
  46. llListenRemove(gListener); // kill the listener after 30 seconds inactivity
  47. }
  48. else if (timereventid == "countdown2execute")
  49. {
  50. float seconds2count = 1800;
  51. llSay(0, "I have counted down " + (string)seconds2count + " seconds, repeat countdown and start the show");
  52. settimeout("countdown2execute", seconds2count); //call it again to loop.
  53. }
  54. else if (timereventid == "autofire")
  55. {
  56. if(gAutofire)
  57. {
  58. llSay(0,"should fire every 5 seconds.");
  59. llRegionSay(20,"Go");
  60. settimeout("autofire", 5);
  61. }
  62. }
  63. if (timereventid == "stopautofire")
  64. {
  65. gAutofire=FALSE;
  66. }
  67. }
  68. timertick()
  69. {
  70. gTimeElapsed += gTimerInterval;
  71. integer i;
  72. integer numTimers = llGetListLength(gTimeoutList);
  73. for (i = 0; i < numTimers; i += 2)
  74. {
  75. float triggerTime = llList2Float(gTimeoutList, i);
  76. if (triggerTime <= gTimeElapsed)
  77. {
  78. string timereventid = llList2String(gTimeoutList, i + 1);
  79. gTimeoutList = llDeleteSubList(gTimeoutList, i, i + 1);
  80. timeout(timereventid);
  81. if (timereventid=="countdown2execute")
  82. {
  83. displaycountdowntext((integer)gTimeElapsed);
  84. getdigit((integer)gTimeElapsed);
  85. }
  86. if (gTimeoutList == [])
  87. llSetTimerEvent(0);
  88. }
  89. else
  90. {
  91. return;
  92. }
  93. }
  94. }
  95. displaydigit(integer n, string d){
  96. list Facelist; //list depends on your mesh digital readout face number.
  97. integer i;
  98. if(n==0) Facelist=[ 1,1,1,1,0,1,1 ]; //index @0 | 7 faces per digit
  99. if(n==1) Facelist=[ 0,0,1,0,0,1,0 ];
  100. if(n==2) Facelist=[ 1,1,0,1,1,1,0 ];
  101. if(n==3) Facelist=[ 1,1,1,0,1,1,0 ];
  102. if(n==4) Facelist=[ 0,0,1,0,1,1,1 ];
  103. if(n==5) Facelist=[ 1,1,1,0,1,0,1 ];
  104. if(n==6) Facelist=[ 0,1,1,1,1,0,1 ];
  105. if(n==7) Facelist=[ 1,0,1,0,0,1,0 ];
  106. if(n==8) Facelist=[ 1,1,1,1,1,1,1 ];
  107. if(n==9) Facelist=[ 1,0,1,0,1,1,1 ];
  108. integer l = llGetLinkNumber() != 0;
  109. integer x = llGetNumberOfPrims() + l;
  110. for (; l < x; ++l){
  111. if (llGetLinkName(l) == d){
  112. for (i=0;i<7;i++){
  113. llSetLinkPrimitiveParamsFast(l,[PRIM_COLOR,i,gFacecolor,llList2Float(Facelist,i)]);
  114. }
  115. }
  116. }
  117. }
  118. getdigit(integer time){
  119. string dOne;
  120. string dTen;
  121. string dHundred;
  122. string dThousand;
  123. integer i;
  124. if (time<10){
  125. dOne=(string)time;
  126. dTen="0";
  127. dHundred="0";
  128. dThousand="0"; // add your digits here
  129. }else if(time<100){
  130. dOne=llGetSubString((string)time,-1,-1);
  131. dTen=llGetSubString((string)time,0,0);
  132. dHundred="0";
  133. dThousand="0";
  134. }else if(time<1000){
  135. dOne=llGetSubString((string)time,-1,-1);
  136. dTen=llGetSubString((string)time,1,1);
  137. dHundred=llGetSubString((string)time,0,0);
  138. dThousand="0";
  139. }else if(time<10000){
  140. dOne=llGetSubString((string)time,-1,-1);
  141. dTen=llGetSubString((string)time,2,2);
  142. dHundred=llGetSubString((string)time,1,1);
  143. dThousand=llGetSubString((string)time,0,0);
  144. }
  145. displaydigit((integer)dOne, "one");
  146. displaydigit((integer)dTen, "ten");
  147. displaydigit((integer)dHundred, "hundred");
  148. displaydigit((integer)dThousand, "thousand");
  149. }
  150. displaycountdowntext(integer time){
  151. gNewTime = time;
  152. if (gOldTime < gNewTime){
  153. llSetText("Elapsed Ticker: " + (string)gNewTime + " ticks",<1,1,.6>,1.0);
  154. gOldTime = gNewTime;
  155. }
  156. }
  157. default
  158. {
  159. state_entry()
  160. {
  161. float seconds2count = 3600;
  162. settimeout("countdown2execute", seconds2count);
  163. }
  164. touch_start(integer num)
  165. {
  166. simplemenu(llDetectedKey(0));
  167. }
  168. listen (integer channel, string name, key id, string message)
  169. {
  170. if (message == "FIREWORKS") {
  171. llSay(0,"You selected option FIREWORKS");
  172. llRegionSay(20,"Go");
  173. //do something else here
  174. }
  175. else if (message == "SARA")
  176. {
  177. llSay(0,"You selected option SARA");
  178. llRegionSay(11,"@go");
  179. //do something else here
  180. }
  181. else if (message == "SAMMY")
  182. {
  183. llSay(0,"You selected option SAMMY");
  184. llRegionSay(12,"@go");
  185. //do something else here
  186. }
  187. else if (message == "CLAIRE")
  188. {
  189. llSay(0,"You selected option CLAIRE");
  190. llRegionSay(13,"@go");
  191. //do something else here
  192. }
  193. else if (message == "JOLINDA")
  194. {
  195. llSay(0,"You selected option JOLINDA");
  196. llRegionSay(14,"@go");
  197. //do something else here
  198. }
  199. else if (message == "TINY")
  200. {
  201. llSay(0,"You selected option TINY");
  202. llRegionSay(15,"@go");
  203. //do something else here
  204. }
  205. else if (message == "TINY2")
  206. {
  207. llSay(0,"You selected option TINY2");
  208. llRegionSay(16,"@go");
  209. //do something else here
  210. }
  211. else if (message == "LeadNPC")
  212. {
  213. llSay(0,"You selected option LeadNPC");
  214. llRegionSay(10,"@go");
  215. //do something else here
  216. }
  217. else if (message == "Finale!")
  218. {
  219. llSay(0,"You selected option Finale!");
  220. gAutofire=TRUE;
  221. settimeout("autofire", 1);
  222. settimeout("stopautofire", 90);
  223. //do something else here
  224. }
  225. else if (message == "CeaseFire")
  226. {
  227. llSay(0,"You selected option CeaseFire");
  228. gAutofire=FALSE;
  229. //do something else here
  230. }
  231. simplemenu(id); // refresh menu
  232. }
  233. timer()
  234. {
  235. timertick();
  236. integer MaxTicks = 1800; //Ticks to countdown from
  237. //limit the ticker to maximum ticks
  238. if(gTimeElapsed >= MaxTicks){
  239. gTimeElapsed=0;
  240. }
  241. integer CountDown = MaxTicks - (integer)gTimeElapsed;
  242. integer mm = (CountDown / 60) * 100;
  243. integer ss = (CountDown % 60);
  244. integer cc = mm + ss;
  245. displaycountdowntext((integer)gTimeElapsed);
  246. getdigit((integer)cc);
  247. }
  248. }