letters.txt 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. sign.started(gamesignloc);
  2. rankingtable = "letterranks";
  3. game_short = "letter";
  4. event.load("block_click");
  5. event.load("player_logout");
  6. event.load("player_giveup");
  7. event.load("player_join");
  8. event.load("living_pre_hurt");
  9. @wait
  10. wait();
  11. if(event == "living_pre_hurt") {
  12. if(!isPlayer(living_entity)) {
  13. goto("wait");
  14. }
  15. player = living_entity;
  16. }
  17. if(player.hasMinigameId(player, script_id)) {
  18. ignoreGoto(event);
  19. }
  20. goto("wait");
  21. @living_pre_hurt
  22. cancel = true;
  23. goto("wait");
  24. @player_join
  25. letters = list.new();
  26. letters2 = list.new();
  27. list.addAll(letters, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
  28. list.addAll(letters2, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
  29. gamename = "§dLetters";
  30. counter = 0;
  31. minutes = 0;
  32. seconds = 0;
  33. this_player = player;
  34. entity.teleport(player, spawnloc);
  35. entity.cleareffects(player);
  36. living.setHealth(player, 20);
  37. player.setHunger(player, 20);
  38. player.setSaturation(player, 5);
  39. title.setTime(player, 20, 0, 20);
  40. title.setSub(player, mapname);
  41. title.send(player, gamename);
  42. nextletter = list.getIndex(letters, counter);
  43. display.reset(player);
  44. display.add(player, 1, gamename);
  45. display.add(player, 2, "Progress:");
  46. display.add(player, 3, concat(text.number(counter), "/26"));
  47. display.add(player, 4, concat("Find: ", nextletter));
  48. display.add(player, 5, concat("Time: 0:00"));
  49. player.clearInventory(player);
  50. if(!fixsigns) {
  51. logcoords = list.new();
  52. signcoords = list.new();
  53. sign_facing = list.new();
  54. }
  55. log_tag = block.getTag("minecraft:logs");
  56. sign_tag = block.getTag("minecraft:signs");
  57. if(!fixsigns) {
  58. x1 = loc.getCoord(edge1, "bx");
  59. y1 = loc.getCoord(edge1, "by");
  60. z1 = loc.getCoord(edge1, "bz");
  61. x2 = loc.getCoord(edge2, "bx");
  62. y2 = loc.getCoord(edge2, "by");
  63. z2 = loc.getCoord(edge2, "bz");
  64. if(x1 > x2) {
  65. helper = x2;
  66. x2 = x1;
  67. x1 = helper;
  68. }
  69. if(z1 > z2) {
  70. helper = z2;
  71. z2 = z1;
  72. z1 = helper;
  73. }
  74. edge1 = loc.new(gamesworld, x1, y1, z1);
  75. xedgedistance = x2 - x1;
  76. zedgedistance = z2 - z1;
  77. for(x = 0; x < xedgedistance; x++) {
  78. for(z = 0; z < zedgedistance; z++) {
  79. relloc = loc.mod(edge1, x, 0, z);
  80. if(block.hasTag(log_tag, block.get(relloc))) {
  81. list.add(logcoords, relloc);
  82. }
  83. if(block.hasTag(sign_tag, block.get(relloc))) {
  84. block.set(relloc, "minecraft:air");
  85. }
  86. }
  87. }
  88. for(i = 0; i < list.getSize(logcoords); i++) {
  89. x = 0;
  90. z = 0;
  91. y = math.random(0, 3);
  92. xz = math.random(0, 1);
  93. if(xz == 0) {
  94. while(x == 0) {
  95. x = math.random(-1, 1);
  96. }
  97. } else {
  98. while(z == 0) {
  99. z = math.random(-1, 1);
  100. }
  101. }
  102. list.add(signcoords, loc.mod(list.getIndex(logcoords, i), x, y, z));
  103. if(x == -1) {
  104. list.add(sign_facing, "west");
  105. } elseif(x == 1) {
  106. list.add(sign_facing, "east");
  107. }
  108. if(z == -1) {
  109. list.add(sign_facing, "north");
  110. } elseif(z == 1) {
  111. list.add(sign_facing, "south");
  112. }
  113. }
  114. for(i = 0; i < list.getSize(signcoords); i++) {
  115. temploc = list.getIndex(signcoords, i);
  116. facing = list.getIndex(sign_facing, i);
  117. block.set(temploc, concat("minecraft:oak_wall_sign[facing=", facing, "]"));
  118. tempindex = math.random(0 , list.getSize(letters2) - 1);
  119. block.setSign(temploc, 0, list.getIndex(letters2, tempindex));
  120. list.removeIndex(letters2, tempindex);
  121. }
  122. } elseif(fixsigns) {
  123. for(i = 0; i < list.getSize(signcoords); i++) {
  124. temploc = list.getIndex(signcoords, i);
  125. tempindex = math.random(0 , list.getSize(letters2) - 1);
  126. block.setSign(temploc, 0, list.getIndex(letters2, tempindex));
  127. list.removeIndex(letters2, tempindex);
  128. }
  129. }
  130. sgoto(20, "loop");
  131. goto("wait");
  132. @loop
  133. seconds++;
  134. if(seconds == 60) {
  135. minutes++;
  136. seconds = 0;
  137. }
  138. if(seconds < 10) {
  139. display.add(this_player, 5, concat("Time: ", text.number(minutes), ":0", text.number(seconds)));
  140. } else {
  141. display.add(this_player, 5, concat("Time: ", text.number(minutes), ":", text.number(seconds)));
  142. }
  143. sgoto(20, "loop");
  144. goto("wait");
  145. @block_click
  146. cancel = true;
  147. if(block.hasTag(sign_tag, block.get(block_loc))) {
  148. letter = block.getSign(block_loc, 0);
  149. if(letter == nextletter) {
  150. counter++;
  151. msg.prefix(player, gamename, concat("Progress: ", text.number(counter), "/26"));
  152. display.add(player, 3, concat(text.number(counter), "/26"));
  153. living.setHealth(player, 20);
  154. player.setHunger(player, 20);
  155. player.setSaturation(player, 5);
  156. if(counter == 26) {
  157. time = minutes * 60 + seconds;
  158. tpl = math.roundComma(time / 26, 2);
  159. player_id = player.getId(player);
  160. played_games = minigame.getPlayed(player_id, game_short) + 1;
  161. minigame.setPlayed(player_id, game_short, played_games);
  162. last_record = ranking.getPoints(rankingtable, player_id);
  163. if(last_record == 0 || time < last_record) {
  164. record = time;
  165. diff = last_record - time;
  166. } else {
  167. record = last_record;
  168. }
  169. ranking.setPoints(rankingtable, player_id, record);
  170. rec_mins = math.roundDown(record / 60);
  171. rec_secs = math.roundComma(record % 60, 2);
  172. minigame.statsHeader(player, gamename, "§e");
  173. minigame.statsLine(player, "§e", "Time", concat(text.number(minutes), " min ", text.number(seconds), " s"));
  174. minigame.statsLine(player, "§e", "Time per Letter", concat(text.number(tpl), " s"));
  175. minigame.statsLine(player, "§e", "Your record", concat(text.number(rec_mins), " min ", text.number(rec_secs), " s"));
  176. if(diff != null) {
  177. msg(player, " §e- §rBeat own record by §e", concat(text.number(diff), " s"));
  178. }
  179. minigame.statsLine(player, "§e", "Played games", text.number(played_games));
  180. money.addBoost(player, 26);
  181. goto("player_giveup");
  182. }
  183. nextletter = list.getIndex(letters, counter);
  184. display.add(player, 4, concat("Find: ", nextletter));
  185. }
  186. }
  187. goto("wait");
  188. @player_logout
  189. @player_giveup
  190. if(!fixsigns) {
  191. for(i = 0; i < list.getSize(signcoords); i++) {
  192. block.set(list.getIndex(signcoords, i), "minecraft:air");
  193. }
  194. }
  195. script = script.getFromId(script_id);
  196. minigame.kickPlayer(script, player);
  197. minigame.term(script, gamesignloc);
  198. term();