game_buzzer.lslp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  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. * Copyright (c) 2011-06 contributors (see below)
  7. * Released under the GNU GPL v3
  8. * -------------------------------------------
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * All scripts must maintain this copyrite information, including the contributer information listed
  24. *
  25. * Developer:
  26. * Paul Preibisch
  27. *
  28. *******************************
  29. * Description *
  30. *******************************
  31. *
  32. * This buzzer script is free for use, and was designed for educators using virtual worlds
  33. * It has now become part of the SLOODLE project, and the AVATARCLASSROOM and licensed under GPL 3.0
  34. * Basically, that means, you are free to use the script, commercially etc, but if you include
  35. * it in your objects, you must make the source viewable to the person you are distributuing it to -
  36. * ie: it can not be closed source - GPL 3.0 means - you must make it open!
  37. *
  38. * This is so that others can modify it and contribute back to the community.
  39. * The SLOODLE github can be found here: https://github.com/sloodle
  40. * Enjoy!
  41. *
  42. * This buzzer can be used for games which require contestants to "hit a buzzer" before
  43. * they can answer a question. To turn the buzzer ON, click on the green ON cylindar at the
  44. * base of the buzzer. A large mechanical arm with a big green click me button will appear.
  45. * Up to three contestants can hit the green cylindar by touching it. When they do
  46. * their names will be listed in order below, in 3 mechanical drawers which pop down
  47. *
  48. *******************************
  49. * The Red Off Button *
  50. *******************************
  51. *
  52. * The large Red Cylindar that says "Off" is used to deactivate clicking - so no user will be able
  53. * to click the buzzer. Click the "Off" button in between questions. When you have asked your question
  54. * you can click the green "On" button, so contestants can click it indicating that they want to answer the question
  55. *
  56. *
  57. ********************************
  58. * The Green On Button *
  59. ********************************
  60. *
  61. * Once you have asked your question, the teacher presses the green "on" button which
  62. * will automatically display a mechanical arm with a large green button attached that says
  63. * "Click Me" when a user clicks the green "Click Me" button, their name will be displayed
  64. * in a large rectangular drawer below the timer. Up to three students can click the green button
  65. *
  66. *******************************
  67. * Using the Count Down Timer *
  68. *******************************
  69. *
  70. * This buzzer also comes with a count down timer.
  71. * The teacher can press the green "start" button to start the count down, and the red "stop" button
  72. * to stop the countdown. This is useful in cases where the teacher wants to give the contestant a time limit in answering
  73. * a question. When the countdown reaches 5 seconds, there will be an audible beeping sound
  74. * and a big buzzer sound at when the buzzer reaches zero.
  75. *
  76. *
  77. **********************
  78. * Setting the Timer *
  79. **********************
  80. *
  81. * The teacher can set the timer by pressing the orange "Set Timer" button at the base of the buzzer, then
  82. * using the iphone like keypad to enter a new time. Press "Set Timer" once more when finished. Each time the user
  83. * presses a keypad, a new digit will be displayed on the surface of the timer, so it is
  84. * easy to see the digits that are being typed in. Note, if you make a mistake, there is a backspace key on the keypad
  85. * which you can press to erase the last digit. The number sign icon does nothing.
  86. *
  87. *******************
  88. * HIDE BUTTON *
  89. *******************
  90. *
  91. * Lastly, there is a large yellow cylindar that says "Hide" - use this to hide the large mechanical arm
  92. * in cases where a game is finished, or you simply want to use this buzzer as a count down timer.
  93. * When teacher is ready, they click the ball, it turns green indicating it is ready to be clicked, count down timer displays
  94. *
  95. *******************
  96. * Sound Licenses.*
  97. *******************
  98. * All sounds were sourced from the http://freesound.org website
  99. * please view their licences below
  100. *
  101. * Kodak Printer sound: http://www.freesound.org/samplesViewSingle.php?id=48667
  102. * http://creativecommons.org/licenses/sampling+/1.0/
  103. * nice.wav visit: http://www.freesound.org/samplesViewSingle.php?id=51488
  104. * beepbeep.wav beep: http://www.freesound.org/samplesViewSingle.php?id=32683
  105. */
  106. key gSetupQueryId; //used for reading settings notecards
  107. list gInventoryList;//used for reading settings notecards
  108. string gSetupNotecardName="config";//used for reading settings notecards
  109. integer gSetupNotecardLine;//used for reading settings notecards
  110. integer SETTEXT_CHANNEL= -8882;
  111. integer SET_COLOR_CHANNEL=-889;
  112. integer SOUND_CHANNEL = -34000;//sound requests
  113. integer TIME_S = 0;
  114. integer TIME_M=1;
  115. integer TIME_H=0;
  116. integer keyPressCount;
  117. integer MAX_TIME;
  118. string editNum="";
  119. integer SETTIMER=FALSE;
  120. string SHOWARM="HIDE";
  121. string editM;
  122. string editS;
  123. string editH;
  124. string SLOODLE_EOF = "sloodleeof";
  125. integer eof= FALSE;
  126. list winners;
  127. list winnerKeys;
  128. list sitters;
  129. list booths;
  130. string myName;
  131. integer buzzerButton;//to identify which link is the buzzerButton
  132. key myKey;
  133. list facilitators;//list of people who can control the buzzer
  134. integer PLUGIN_RESPONSE_CHANNEL =998822; //sloodle_api.lsl responses
  135. integer PLUGIN_CHANNEL =998821;//sloodle_api requests
  136. integer UI_CHANNEL =89997;//UI Channel - main channel
  137. integer ROW_CHANNEL;
  138. // *************************************************** HOVER TEXT COLORS
  139. vector RED = <0.77278, 0.04391, 0.00000>;//RED
  140. vector YELLOW = <0.82192, 0.86066, 0.00000>;//YELLOW
  141. vector GREEN = <0.12616, 0.77712, 0.00000>;//GREEN
  142. vector PINK = <0.83635, 0.00000, 0.88019>;//INDIGO
  143. vector WHITE = <1.000, 1.000, 1.000>;//WHITE
  144. integer MENU_CHANNEL;
  145. integer XY_1= -999821;
  146. integer XY_2= -999822;
  147. integer XY_3= -999823;
  148. integer XY_TIMER= -999824;
  149. integer XY_AWARD_NAME= -999825;
  150. integer counter;
  151. list modButs = ["+10","+30","-10","-30","+60","-60","+300","-300"];
  152. list pointMods=["-5","-10","-100","-500","-1000","+5","+10","+100","+500","+1000","~~ SAVE ~~"]; //this is a list of values an owner can modify a users points to //["-5","-10","-100","-500","-1000","+5","+10","+100","+500","+1000",
  153. list modifyPointList; //this is a temp list that is used to store point modifications in. When Save is pressed on a menu, these points are applied to the users point bank
  154. integer modPoints;
  155. integer currentAwardId;
  156. string currentAwardName;
  157. list primNames;
  158. //deletes an item from a list
  159. list ListItemDelete(list mylist,string element_old) {
  160. integer placeinlist = llListFindList(mylist, [element_old]);
  161. if (placeinlist != -1){
  162. return llDeleteSubList(mylist, placeinlist, placeinlist);
  163. }
  164. return mylist;
  165. }//listitemdelete
  166. //clear the timer screen
  167. clear(){
  168. llMessageLinked(LINK_SET, XY_1," ", NULL_KEY);
  169. llMessageLinked(LINK_SET, XY_2," ", NULL_KEY);
  170. llMessageLinked(LINK_SET, XY_3," ", NULL_KEY);
  171. }
  172. //center the xy text s, which is of length len, and listens to channel
  173. center(string s,integer len,integer channel){
  174. integer marginLen= (integer)(len-llStringLength((string)s))/2;
  175. integer j;
  176. string spaces="";
  177. for (j=0;j<len*10+1;++j){
  178. spaces+=" ";
  179. }
  180. string margin = llGetSubString(spaces, 0, marginLen);
  181. string text = margin + (string)(s)+margin;
  182. llMessageLinked(LINK_SET, channel,text , NULL_KEY);
  183. }
  184. //returns the link number of the prim named pName
  185. integer getLink(string pName){
  186. return (llListFindList(primNames,[pName]));
  187. }
  188. //gets a vector from a string
  189. vector getVector(string vStr){
  190. vStr=llGetSubString(vStr, 1, llStringLength(vStr)-2);
  191. list vStrList= llParseString2List(vStr, [","], ["<",">"]);
  192. vector output= <llList2Float(vStrList,0),llList2Float(vStrList,1),llList2Float(vStrList,2)>;
  193. return output;
  194. }//end getVector
  195. rotation getRot(string vStr){
  196. vStr=llGetSubString(vStr, 1, llStringLength(vStr)-2);
  197. list vStrList= llParseString2List(vStr, [","], ["<",">"]);
  198. rotation output= <llList2Float(vStrList,0),llList2Float(vStrList,1),llList2Float(vStrList,2),llList2Float(vStrList,3)>;
  199. return output;
  200. }//end getRot
  201. /***********************************************************************************************
  202. * s() k() i() and v() are used so that sending messages is more readable by humans.
  203. * Ie: instead of sending a linked message as
  204. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  205. * Context is added with a tag: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  206. * All these functions do is strip off the text before the ":" char and return a string
  207. ***********************************************************************************************/
  208. string s (string ss){
  209. return llList2String(llParseString2List(ss, [":"], []),1);
  210. }//end function
  211. key k (string kk){
  212. return llList2Key(llParseString2List(kk, [":"], []),1);
  213. }//end function
  214. integer i (string ii){
  215. return llList2Integer(llParseString2List(ii, [":"], []),1);
  216. }//end function
  217. vector v (string vv){
  218. integer p = llSubStringIndex(vv, ":");
  219. string vString = llGetSubString(vv, p+1, llStringLength(vv));
  220. return getVector(vString);
  221. }//end function
  222. rotation r (string rr){
  223. integer p = llSubStringIndex(rr, ":");
  224. string rString = llGetSubString(rr, p+1, llStringLength(rr));
  225. return getRot(rString);
  226. }//end function
  227. preloadSounds(){
  228. key buzzer = "SND_BUZZER";
  229. llPreloadSound(buzzer);
  230. key tick = "SND_TICK";
  231. llPreloadSound(tick);
  232. key beepbeep = "SND_BEEPBEEP";
  233. llPreloadSound(beepbeep);
  234. key onetype = "SND_TYPE";
  235. llPreloadSound(onetype );
  236. key ipress = "SND_IPRESS";
  237. llPreloadSound(ipress );
  238. key pd = "SND_POWER_DOWN";
  239. llPreloadSound(pd );
  240. key iopen = "cf218344-0251-6bfd-acba-fdd5534861b1";
  241. llPreloadSound(iopen );
  242. }
  243. /***********************************************
  244. * isFacilitator()
  245. * |-->is this person's name in the access notecard
  246. ***********************************************/
  247. integer isFacilitator(string avName){
  248. if (llListFindList(facilitators, [llToLower(avName)])==-1) return FALSE; else return TRUE;
  249. }
  250. /***********************************************
  251. * getMaxTime(integer seconds,integer minutes,integer hours)
  252. * |-->gets thenumber of seconds
  253. ***********************************************/
  254. integer getSeconds(string seconds,string minutes,string hours){
  255. integer timeLeft = i(seconds)+60*i(minutes)+3600*i(hours);
  256. return timeLeft;
  257. }
  258. /***********************************************
  259. * getMaxTime(integer seconds,integer minutes,integer hours)
  260. * |-->gets thenumber of seconds and returns a formated list 00:00:00
  261. ***********************************************/
  262. string getTime(integer seconds){
  263. integer hours = (integer)(seconds/3600);
  264. integer minutes = (integer)((seconds/60)- (hours*60));
  265. integer s = (integer)(seconds%60);
  266. if (s ==60) {
  267. minutes+=1;
  268. s = 0;
  269. }
  270. if (minutes==60){
  271. hours+=1;
  272. minutes=0;
  273. }
  274. string sString;
  275. string mString;
  276. string hString;
  277. if (llStringLength((string)s)==1) {
  278. sString= "0"+(string)s;
  279. }else sString = (string)s;
  280. if (llStringLength((string)minutes)==1) {
  281. mString= "0"+(string)minutes;
  282. }else mString = (string)minutes;
  283. if (llStringLength((string)hours)==1) {
  284. hString= "0"+(string)hours;
  285. }else hString = (string)hours;
  286. return hString+":"+mString+":"+sString;
  287. }
  288. /***********************************************
  289. * random_integer()
  290. * |-->Produces a random integer
  291. ***********************************************/
  292. integer random_integer( integer min, integer max )
  293. {
  294. return min + (integer)( llFrand( max - min + 1 ) );
  295. }
  296. string setTime;
  297. integer isconfigured=FALSE;
  298. integer newChannel;
  299. 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.
  300. string time="00:00:00";
  301. integer sloodle_handle_command(string str)
  302. {
  303. list bits = llParseString2List(str,["|"],[]);
  304. integer numbits = llGetListLength(bits);
  305. string name = llList2String(bits,0);
  306. string value1 = "";
  307. string value2 = "";
  308. if (numbits > 1) value1 = llList2String(bits,1);
  309. if (numbits > 2) value2 = llList2String(bits,2);
  310. if (name == "set:facilitator"){
  311. facilitators+=llToLower(value1);
  312. }else
  313. if (name == "set:time"){
  314. time= (string)value1;
  315. center(time,10,XY_TIMER);
  316. }
  317. else if (name == SLOODLE_EOF){
  318. eof = TRUE;
  319. return (time != "00:00:00");
  320. }
  321. return FALSE;
  322. }
  323. default {
  324. state_entry() {
  325. facilitators+=llToLower(llKey2Name(llGetOwner()));
  326. llTriggerSound("SND_STARTING_UP",1.0);//starting up
  327. MAX_TIME = TIME_S + TIME_M*60+TIME_H*3600;
  328. //get number of linked prims
  329. integer numPrims = llGetNumberOfPrims();
  330. //find out which one is buzzer prim
  331. integer j;
  332. for (j=0;j<=numPrims;j++){
  333. primNames +=llGetLinkName(j);
  334. }//endfor
  335. llMessageLinked(LINK_SET, 1, "p0",NULL_KEY);
  336. myName = llGetObjectName();
  337. myKey = llGetKey();
  338. MENU_CHANNEL = random_integer(2000,3000);
  339. ROW_CHANNEL=random_integer(2483000,3483000);
  340. state ready;
  341. }//end state_entry
  342. on_rez(integer start_param) {
  343. llResetScript();
  344. }
  345. link_message( integer sender_num, integer num, string str, key id)
  346. {
  347. // Check the channel
  348. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  349. // Split the message into lines
  350. list lines = llParseString2List(str, ["\n"], []);
  351. integer numlines = llGetListLength(lines);
  352. integer i = 0;
  353. for (i=0; i < numlines; i++) {
  354. isconfigured = sloodle_handle_command(llList2String(lines, i));
  355. }if (isconfigured){
  356. state ready;
  357. }
  358. }
  359. }
  360. changed(integer change) { // something changed
  361. if (change ==CHANGED_INVENTORY){
  362. llResetScript();
  363. }//endif
  364. }
  365. }//end default
  366. //waiting for teacher to touch it
  367. state ready{
  368. on_rez(integer start_param) {
  369. llResetScript();
  370. }
  371. state_entry() {
  372. llTriggerSound("SND_LOADING_COMPLETE", 1.0);//loading complete
  373. llOwnerSay("Ready! Click the green cylindar to engage the buzzer!\nPress the red cylindar to disengage the buzzer, and the yellow cylindar to hide it!");
  374. integer j=0;
  375. integer len = llGetListLength(booths);
  376. /****************************************
  377. * INITIALIZE
  378. *****************************************/
  379. llSetTimerEvent(0);
  380. //move arm to waiting position
  381. llMessageLinked(LINK_SET, 1, "p1",NULL_KEY);
  382. winners=[];
  383. winnerKeys=[];
  384. modifyPointList=[0,0,0];
  385. /****************************************
  386. * PLAY SOUNDS
  387. *****************************************/
  388. llTriggerSound("SND_FAST_KODAK", 1.0);
  389. /****************************************
  390. * INIT DISPLAY
  391. *****************************************/
  392. //center text
  393. //set hover text
  394. llMessageLinked(LINK_SET,SETTEXT_CHANNEL,"DISPLAY::top display|STRING::Ready:|COLOR::"+(string)RED+"|ALPHA::1.0",NULL_KEY);
  395. //clear text
  396. clear();
  397. //set red
  398. llMessageLinked(LINK_SET,SET_COLOR_CHANNEL,"COMMAND:SET COLOR|PRIM:buzzer_button|COLOR:RED",NULL_KEY);
  399. }//end state_entry
  400. touch_start(integer num_detected) {
  401. //each prim that has a blink.lsl script in it, will set its glow to .90 for 1 second when this message is received
  402. integer j;
  403. for (j=0;j<num_detected;j++){
  404. string butName = llGetLinkName(llDetectedLinkNumber(j));
  405. if (isFacilitator(llDetectedName(j))){
  406. llMessageLinked(LINK_SET, UI_CHANNEL, "COMMAND:BLINK|PRIM:"+butName, NULL_KEY);
  407. if (butName=="hide_arm_button"){
  408. llMessageLinked(LINK_SET, 1, "p0",NULL_KEY);
  409. llTriggerSound("SND_FAST_KODAK", 1.0);//fastkodak
  410. return;
  411. }//endif
  412. else
  413. if (butName=="dock_arm"){
  414. // if (SHOWARM=="SHOW"){
  415. llSetLinkPrimitiveParams(getLink("buzzer_button"), [PRIM_COLOR, ALL_SIDES, RED, 1.0,
  416. PRIM_TEXTURE, 0, "blank",<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]);
  417. llTriggerSound("SND_POWER_DOWN", 1.0);//power down
  418. llMessageLinked(LINK_SET, 1, "p1",NULL_KEY);
  419. SHOWARM="HIDE";
  420. return;
  421. // }//SHOWARM
  422. }//endifndif
  423. else
  424. if (butName=="show_arm"){
  425. SHOWARM="SHOW";
  426. llMessageLinked(LINK_SET, UI_CHANNEL, "COMMAND:BLINK|PRIM:timer", NULL_KEY);
  427. llTriggerSound("SND_POWER_UP", 1.0);
  428. llSetLinkPrimitiveParams(getLink("buzzer_button"), [PRIM_COLOR, ALL_SIDES, GREEN, 1.0,
  429. PRIM_TEXTURE, 0, "click",<1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0 ]);
  430. llMessageLinked(LINK_SET, 1, "p2",NULL_KEY);
  431. llTriggerSound("SND_FAST_KODAK", 1.0);//fastkodak
  432. winners=[];
  433. return;
  434. }//endif
  435. else
  436. if (butName=="hide_arm_button"){
  437. SHOWARM="HIDE";
  438. }//endif
  439. else
  440. if (butName=="stopwatch_button"){
  441. llTriggerSound("SND_SPACE_CODE", 1.0);//SPACCODE buzzer button press
  442. llSetTimerEvent(0);
  443. SETTIMER=FALSE;
  444. return;
  445. }//endif
  446. else
  447. if (butName=="resetwatch_button"){
  448. llTriggerSound("SND_SPACE_CODE", 1.0);//SPACCODE buzzer button press
  449. llSetTimerEvent(0);
  450. counter=0;
  451. MAX_TIME= TIME_S + TIME_M*60+TIME_H*3600;
  452. SETTIMER=FALSE;
  453. integer timeLeft = MAX_TIME-counter;
  454. string printTime = getTime(timeLeft);
  455. center(printTime,10,XY_TIMER);
  456. return;
  457. }//endif
  458. else
  459. if (butName=="startwatch_button"){
  460. if (SETTIMER==TRUE){
  461. TIME_S = (integer)llGetSubString(editNum, 6,7);
  462. TIME_M =(integer)llGetSubString(editNum, 3,4);
  463. TIME_H = (integer)llGetSubString(editNum, 0,1);
  464. SETTIMER==FALSE;
  465. }
  466. MAX_TIME= TIME_S + TIME_M*60+TIME_H*3600;
  467. llTriggerSound("SND_SPACE_CODE", 1.0);//SPACCODE buzzer button press
  468. llSetTimerEvent(1);
  469. return;
  470. }//endif
  471. else
  472. if (butName=="set_timer"){
  473. llTriggerSound("SND_INTERFACE_PRESS", 1.0);//interface press
  474. llSetTimerEvent(0);
  475. keyPressCount=0;
  476. if (SETTIMER==TRUE){
  477. //Sound source: http://www.freesound.org/samplesViewSingle.php?id=2329
  478. //license: http://creativecommons.org/licenses/sampling+/1.0/
  479. llTriggerSound("SND_CONFIRMED", 1.0);//confirmed
  480. TIME_S = (integer)llGetSubString(editNum, 6,7);
  481. TIME_M =(integer)llGetSubString(editNum, 3,4);
  482. TIME_H = (integer)llGetSubString(editNum, 0,1);
  483. MAX_TIME= TIME_S + TIME_M*60+TIME_H*3600;
  484. SETTIMER=FALSE;
  485. integer timeLeft = MAX_TIME-counter;
  486. string printTime = getTime(timeLeft);
  487. center(printTime,10,XY_TIMER);
  488. }else {
  489. editNum="00:00:00";
  490. SETTIMER=TRUE;
  491. }
  492. return;
  493. }//endif
  494. else
  495. if (butName=="backspace"){
  496. if (SETTIMER==TRUE){
  497. if (llStringLength(editNum)==1) editNum="";
  498. else editNum= llGetSubString(editNum,0,llStringLength(editNum)-2);
  499. llTriggerSound("SND_TYPE", 1.0);//one type
  500. center(editNum,10,XY_TIMER);
  501. }//SETTIMER
  502. return;
  503. }//backspace
  504. else
  505. if (llListFindList(["b1","b2","b3","b4","b5","b6","b7","b8","b9","b0"],[butName])!=-1){
  506. if (SETTIMER==TRUE){
  507. counter=0;
  508. keyPressCount++;
  509. string printTime ="";
  510. string num = llGetSubString(butName,1,1);
  511. if (keyPressCount==1) editNum =llGetSubString(editNum, 0, 6)+num; else
  512. if (keyPressCount==2) editNum =llGetSubString(editNum, 0, 5) +llGetSubString(editNum, 7, 7) + num; else
  513. if (keyPressCount==3) editNum =llGetSubString(editNum, 0, 3) +llGetSubString(editNum, 6, 6) +":" +llGetSubString(editNum, 7, 7) + num; else
  514. if (keyPressCount==4) editNum =llGetSubString(editNum, 0, 2) +llGetSubString(editNum, 4, 4) +llGetSubString(editNum, 6, 6) + ":" +llGetSubString(editNum, 7, 7) + num; else
  515. if (keyPressCount==5) editNum ="0"+llGetSubString(editNum, 3, 3) +":"+llGetSubString(editNum, 4, 4) +llGetSubString(editNum, 6, 6) + ":" +llGetSubString(editNum, 7, 7) + num; else
  516. if (keyPressCount==6) editNum =llGetSubString(editNum, 1, 1) +llGetSubString(editNum, 3, 3)+":" +llGetSubString(editNum, 4, 4) +llGetSubString(editNum, 6, 6) + ":" +llGetSubString(editNum, 7, 7) + num;
  517. setTime = editNum;
  518. center(editNum,10,XY_TIMER);
  519. llTriggerSound("SND_TYPE", 1.0);//one type
  520. }//SETTIMER==TRUE
  521. return;
  522. }//end if llListFind
  523. }//end if facilitator
  524. else
  525. if (butName!="buzzer_button") llSay(0,"Sorry, you need to be a facilitator to use this function. Facilitators are: "+(string)llList2CSV(facilitators));
  526. /********************************************************
  527. * Player clicks
  528. *********************************************************/
  529. if (butName=="buzzer_button"){
  530. // llSay(0,(string)llList2CSV(sitters)+"**********"+(string)llDetectedKey(0));
  531. // if (llListFindList(sitters, [llDetectedKey(0)])!=-1){
  532. //llMessageLinked(LINK_SET,SOUND_CHANNEL, "COMMAND:PLAYSOUND|SOUND:beep|SCRIPT_NAME:soundPlayer 1|VOLUME:1.0",NULL_KEY);
  533. integer printChannel;
  534. string userName=llDetectedName(j);
  535. key userKey = llDetectedKey(j);
  536. if (SHOWARM=="SHOW"){
  537. // if (llListFindList(sitters, [llDetectedKey(0)])!=-1){
  538. llMessageLinked(LINK_SET, UI_CHANNEL, "COMMAND:BLINK|PRIM:"+butName, NULL_KEY);
  539. //only 3 people are allowed to click
  540. if (llListFindList(winners, [userName])==-1){
  541. //if hasnt been added, add to winners
  542. winners+=userName;
  543. winnerKeys+=userKey;
  544. //get number of winners
  545. integer numWinners = llGetListLength(winners);
  546. string anim="p3";
  547. if (numWinners<4){
  548. //play buzzer sound if one of the first 3 to click
  549. llTriggerSound("SND_GAME_BUZZER_HIT", 1.0);//game_show_buzzer_hit
  550. if (numWinners ==1){
  551. printChannel=XY_1;
  552. anim = "p3";
  553. }else
  554. if (numWinners ==2){
  555. printChannel=XY_2;
  556. anim ="p4";
  557. }else
  558. if (numWinners ==3){
  559. printChannel=XY_3;
  560. anim ="p5";
  561. }
  562. //only print username on scoreboard if one of the first 3 to click
  563. llMessageLinked(LINK_SET, printChannel,userName, NULL_KEY);
  564. //play animation
  565. llMessageLinked(LINK_SET, 1, anim,NULL_KEY);
  566. return;
  567. }//endif numWinners < 4
  568. }//findlist winners
  569. // }//findlist sitters
  570. } //showarm
  571. // }//findlist sitters
  572. }//end if buttname
  573. }
  574. }//end touch
  575. timer() {
  576. //gets thenumber of seconds and returns a formated list 00:00:00
  577. integer timeLeft = MAX_TIME-counter;
  578. string printTime = getTime(timeLeft);
  579. center(printTime,10,XY_TIMER);
  580. ++counter;
  581. if (timeLeft<5){
  582. llTriggerSound("SND_BEEPBEEP", 1.0);//beep beepbeep beep
  583. }else
  584. llTriggerSound("SND_TICK", 1.0);//tick
  585. if (counter>MAX_TIME){
  586. llSetTimerEvent(0.0);
  587. llMessageLinked(LINK_SET, 1, "bp0",NULL_KEY);
  588. counter=0;
  589. center("00:00:00",10,XY_TIMER);
  590. llTriggerSound("SND_BUZZER", 1.0);//buzzer
  591. }
  592. }//end timer
  593. changed(integer change) { // something changed
  594. if (change ==CHANGED_INVENTORY){
  595. llResetScript();
  596. }//endif
  597. }
  598. }//end state
  599. // Please leave the following line intact to show where the script lives in Git:
  600. // SLOODLE LSL Script Git Location: mod/gaming-1.0/objects/gamebuzzer/assets/game_buzzer.lslp