123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- block.setSign(gamesignloc, 2, "1/1");
- block.setSign(gamesignloc, 3, "§bLäuft");
- event.load("block_click");
- event.load("player_logout");
- event.load("player_giveup");
- rankingtable = "buttonranks";
- registerRanking(rankingtable);
- clicked = 0;
- checked = 0;
- tfn = 5; //timeForNext in sec
- factor = 0.985; //neuer tfn *= factor; Faktor, um den tfn vermindert wird
- player = script.getLeader();
- gamename = "§2Buttons";
- entity.teleport(player, startloc);
- display.reset(player);
- display.add(player, 1, gamename);
- display.add(player, 2, "Time for Click");
- display.add(player, 3, math.roundComma(tfn, 2));
- display.add(player, 4, "Punkte: ", text.number(clicked));
- entity.setHealth(player, 20);
- player.setHunger(player, 20);
- player.setSaturation(player, 5);
- player.speak(player, "§2Buttons", "§rKlicke den Knopf an, bevor die Zeit abläuft");
- player.clearInventory(player);
- sgoto(tfn * 20, "gameover");
- @nextbutton
- while(toclick == lastclick) {
- toclick = list.getIndex(buttons, math.random(0, list.getSize(buttons) - 1));
- }
- if(direction == "x") {
- markedloc = loc.mod(toclick, number, 0, 0);
- block.set(markedloc, markblock);
- } elseif(direction == "z") {
- markedloc = loc.mod(toclick, 0, 0, number);
- block.set(markedloc, markblock);
- }
- goto("wait");
- @wait
- wait();
- ignoreGoto(event);
- goto("wait");
- @block_click
- cancel = true;
- if(block_loc == toclick) {
- tfn *= 0.98;
- tfn = math.roundComma(tfn, 2);
- display.add(player, 3, tfn);
- display.add(player, 4, "Punkte: ", text.number(++clicked));
- sgoto(tfn * 20, "gameover");
- block.set(markedloc, originblock);
- lastclick = toclick;
- goto("nextbutton");
- } else {
- player.speak(player, gamename, "§rDu hast falsch geklickt");
- goto("coregameover");
- }
- goto("wait");
- @gameover
- if(++checked > clicked) {
- player.speak(player, gamename, "§rDu warst zu langsam");
- goto("coregameover");
- }
- goto("wait");
- @coregameover
- player_id = player.getId(player);
- last_record = getPoints(rankingtable, player_id);
- playedgames = getPlayedGames(rankingtable, player_id) + 1;
- player.speak(player, gamename, "§r---= §2Statistik §r=---");
- player.speak(player, "§2-", concat("§rPunkte: §2", text.number(clicked)));
- if(last_record < clicked) {
- record = clicked;
- diff = clicked - last_record;
- player.speak(player, "§2-", concat("§rEigenen Rekord um §2", text.number(diff), "§r übertroffen"));
- } else {
- record = last_record;
- }
- setRanking(rankingtable, player_id, record, playedgames);
- player.speak(player, "§2-", concat("§rDein Rekord: §2", text.number(last_record)));
- player.speak(player, "§2-", concat("§rGespielte Spiele: §2", text.number(playedgames)));
- @player_giveup
- @player_logout
- entity.teleport(player, gamesworldloc);
- resetplayer(player);
- block.set(markedloc, originblock);
- block.setSign(gamesignloc, 2, "0/1");
- block.setSign(gamesignloc, 3, "§2Wartet");
- n = 0;
- while(worker.hasWork()) {
- waitfor(5);
- if(++n == 8) {
- break;
- }
- }
- term();
|