buttons.txt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. block.setSign(gamesignloc, 2, "1/1");
  2. block.setSign(gamesignloc, 3, "§bLäuft");
  3. event.load("block_click");
  4. event.load("player_logout");
  5. event.load("player_giveup");
  6. rankingtable = "buttonranks";
  7. registerRanking(rankingtable);
  8. clicked = 0;
  9. checked = 0;
  10. tfn = 5; //timeForNext in sec
  11. factor = 0.985; //neuer tfn *= factor; Faktor, um den tfn vermindert wird
  12. player = script.getLeader();
  13. gamename = "§2Buttons";
  14. entity.teleport(player, startloc);
  15. display.reset(player);
  16. display.add(player, 1, gamename);
  17. display.add(player, 2, "Time for Click");
  18. display.add(player, 3, math.roundComma(tfn, 2));
  19. display.add(player, 4, "Punkte: ", text.number(clicked));
  20. entity.setHealth(player, 20);
  21. player.setHunger(player, 20);
  22. player.setSaturation(player, 5);
  23. player.speak(player, "§2Buttons", "§rKlicke den Knopf an, bevor die Zeit abläuft");
  24. player.clearInventory(player);
  25. sgoto(tfn * 20, "gameover");
  26. @nextbutton
  27. while(toclick == lastclick) {
  28. toclick = list.getIndex(buttons, math.random(0, list.getSize(buttons) - 1));
  29. }
  30. if(direction == "x") {
  31. markedloc = loc.mod(toclick, number, 0, 0);
  32. block.set(markedloc, markblock);
  33. } elseif(direction == "z") {
  34. markedloc = loc.mod(toclick, 0, 0, number);
  35. block.set(markedloc, markblock);
  36. }
  37. goto("wait");
  38. @wait
  39. wait();
  40. ignoreGoto(event);
  41. goto("wait");
  42. @block_click
  43. cancel = true;
  44. if(block_loc == toclick) {
  45. tfn *= 0.98;
  46. tfn = math.roundComma(tfn, 2);
  47. display.add(player, 3, tfn);
  48. display.add(player, 4, "Punkte: ", text.number(++clicked));
  49. sgoto(tfn * 20, "gameover");
  50. block.set(markedloc, originblock);
  51. lastclick = toclick;
  52. goto("nextbutton");
  53. } else {
  54. player.speak(player, gamename, "§rDu hast falsch geklickt");
  55. goto("coregameover");
  56. }
  57. goto("wait");
  58. @gameover
  59. if(++checked > clicked) {
  60. player.speak(player, gamename, "§rDu warst zu langsam");
  61. goto("coregameover");
  62. }
  63. goto("wait");
  64. @coregameover
  65. player_id = player.getId(player);
  66. last_record = getPoints(rankingtable, player_id);
  67. playedgames = getPlayedGames(rankingtable, player_id) + 1;
  68. player.speak(player, gamename, "§r---= §2Statistik §r=---");
  69. player.speak(player, "§2-", concat("§rPunkte: §2", text.number(clicked)));
  70. if(last_record < clicked) {
  71. record = clicked;
  72. diff = clicked - last_record;
  73. player.speak(player, "§2-", concat("§rEigenen Rekord um §2", text.number(diff), "§r übertroffen"));
  74. } else {
  75. record = last_record;
  76. }
  77. setRanking(rankingtable, player_id, record, playedgames);
  78. player.speak(player, "§2-", concat("§rDein Rekord: §2", text.number(last_record)));
  79. player.speak(player, "§2-", concat("§rGespielte Spiele: §2", text.number(playedgames)));
  80. @player_giveup
  81. @player_logout
  82. entity.teleport(player, gamesworldloc);
  83. resetplayer(player);
  84. block.set(markedloc, originblock);
  85. block.setSign(gamesignloc, 2, "0/1");
  86. block.setSign(gamesignloc, 3, "§2Wartet");
  87. n = 0;
  88. while(worker.hasWork()) {
  89. waitfor(5);
  90. if(++n == 8) {
  91. break;
  92. }
  93. }
  94. term();