123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- sign.started(gamesignloc);
- rankingtable = "letterranks";
- game_short = "letter";
- event.load("block_click");
- event.load("player_logout");
- event.load("player_giveup");
- event.load("player_join");
- event.load("living_pre_hurt");
- @wait
- wait();
- if(event == "living_pre_hurt") {
- if(!isPlayer(living_entity)) {
- goto("wait");
- }
- player = living_entity;
- }
- if(player.hasMinigameId(player, script_id)) {
- ignoreGoto(event);
- }
- goto("wait");
- @living_pre_hurt
- cancel = true;
- goto("wait");
- @player_join
- letters = list.new();
- letters2 = list.new();
- 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");
- 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");
- gamename = "§dLetters";
- counter = 0;
- minutes = 0;
- seconds = 0;
- this_player = player;
- entity.teleport(player, spawnloc);
- entity.cleareffects(player);
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- title.setTime(player, 20, 0, 20);
- title.setSub(player, mapname);
- title.send(player, gamename);
- nextletter = list.getIndex(letters, counter);
- display.reset(player);
- display.add(player, 1, gamename);
- display.add(player, 2, "Progress:");
- display.add(player, 3, concat(text.number(counter), "/26"));
- display.add(player, 4, concat("Find: ", nextletter));
- display.add(player, 5, concat("Time: 0:00"));
- player.clearInventory(player);
- if(!fixsigns) {
- logcoords = list.new();
- signcoords = list.new();
- sign_facing = list.new();
- }
- log_tag = block.getTag("minecraft:logs");
- sign_tag = block.getTag("minecraft:signs");
- if(!fixsigns) {
- x1 = loc.getCoord(edge1, "bx");
- y1 = loc.getCoord(edge1, "by");
- z1 = loc.getCoord(edge1, "bz");
- x2 = loc.getCoord(edge2, "bx");
- y2 = loc.getCoord(edge2, "by");
- z2 = loc.getCoord(edge2, "bz");
- if(x1 > x2) {
- helper = x2;
- x2 = x1;
- x1 = helper;
- }
- if(z1 > z2) {
- helper = z2;
- z2 = z1;
- z1 = helper;
- }
- edge1 = loc.new(gamesworld, x1, y1, z1);
- xedgedistance = x2 - x1;
- zedgedistance = z2 - z1;
- for(x = 0; x < xedgedistance; x++) {
- for(z = 0; z < zedgedistance; z++) {
- relloc = loc.mod(edge1, x, 0, z);
- if(block.hasTag(log_tag, block.get(relloc))) {
- list.add(logcoords, relloc);
- }
- if(block.hasTag(sign_tag, block.get(relloc))) {
- block.set(relloc, "minecraft:air");
- }
- }
- }
- for(i = 0; i < list.getSize(logcoords); i++) {
- x = 0;
- z = 0;
- y = math.random(0, 3);
- xz = math.random(0, 1);
- if(xz == 0) {
- while(x == 0) {
- x = math.random(-1, 1);
- }
- } else {
- while(z == 0) {
- z = math.random(-1, 1);
- }
- }
- list.add(signcoords, loc.mod(list.getIndex(logcoords, i), x, y, z));
- if(x == -1) {
- list.add(sign_facing, "west");
- } elseif(x == 1) {
- list.add(sign_facing, "east");
- }
- if(z == -1) {
- list.add(sign_facing, "north");
- } elseif(z == 1) {
- list.add(sign_facing, "south");
- }
- }
- for(i = 0; i < list.getSize(signcoords); i++) {
- temploc = list.getIndex(signcoords, i);
- facing = list.getIndex(sign_facing, i);
- block.set(temploc, concat("minecraft:oak_wall_sign[facing=", facing, "]"));
- tempindex = math.random(0 , list.getSize(letters2) - 1);
- block.setSign(temploc, 0, list.getIndex(letters2, tempindex));
- list.removeIndex(letters2, tempindex);
- }
- } elseif(fixsigns) {
- for(i = 0; i < list.getSize(signcoords); i++) {
- temploc = list.getIndex(signcoords, i);
- tempindex = math.random(0 , list.getSize(letters2) - 1);
- block.setSign(temploc, 0, list.getIndex(letters2, tempindex));
- list.removeIndex(letters2, tempindex);
- }
- }
- sgoto(20, "loop");
- goto("wait");
- @loop
- seconds++;
- if(seconds == 60) {
- minutes++;
- seconds = 0;
- }
- if(seconds < 10) {
- display.add(this_player, 5, concat("Time: ", text.number(minutes), ":0", text.number(seconds)));
- } else {
- display.add(this_player, 5, concat("Time: ", text.number(minutes), ":", text.number(seconds)));
- }
- sgoto(20, "loop");
- goto("wait");
- @block_click
- cancel = true;
- if(block.hasTag(sign_tag, block.get(block_loc))) {
- letter = block.getSign(block_loc, 0);
- if(letter == nextletter) {
- counter++;
- msg.prefix(player, gamename, concat("Progress: ", text.number(counter), "/26"));
- display.add(player, 3, concat(text.number(counter), "/26"));
- living.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- if(counter == 26) {
- time = minutes * 60 + seconds;
- tpl = math.roundComma(time / 26, 2);
- player_id = player.getId(player);
- played_games = minigame.getPlayed(player_id, game_short) + 1;
- minigame.setPlayed(player_id, game_short, played_games);
- last_record = ranking.getPoints(rankingtable, player_id);
- if(last_record == 0 || time < last_record) {
- record = time;
- diff = last_record - time;
- } else {
- record = last_record;
- }
- ranking.setPoints(rankingtable, player_id, record);
- rec_mins = math.roundDown(record / 60);
- rec_secs = math.roundComma(record % 60, 2);
-
- minigame.statsHeader(player, gamename, "§e");
- minigame.statsLine(player, "§e", "Time", concat(text.number(minutes), " min ", text.number(seconds), " s"));
- minigame.statsLine(player, "§e", "Time per Letter", concat(text.number(tpl), " s"));
- minigame.statsLine(player, "§e", "Your record", concat(text.number(rec_mins), " min ", text.number(rec_secs), " s"));
- if(diff != null) {
- msg(player, " §e- §rBeat own record by §e", concat(text.number(diff), " s"));
- }
- minigame.statsLine(player, "§e", "Played games", text.number(played_games));
- money.addBoost(player, 26);
- goto("player_giveup");
- }
- nextletter = list.getIndex(letters, counter);
- display.add(player, 4, concat("Find: ", nextletter));
- }
- }
- goto("wait");
- @player_logout
- @player_giveup
- if(!fixsigns) {
- for(i = 0; i < list.getSize(signcoords); i++) {
- block.set(list.getIndex(signcoords, i), "minecraft:air");
- }
- }
- script = script.getFromId(script_id);
- minigame.kickPlayer(script, player);
- minigame.term(script, gamesignloc);
- term();
|