SHOW:
|
|
- or go back to the newest paste.
| 1 | players = {}
| |
| 2 | timer = 0 | |
| 3 | countdown = 6 | |
| 4 | player = nil | |
| 5 | ending = false | |
| 6 | difficulty = 1 | |
| 7 | highscore = 0 | |
| 8 | ||
| 9 | function main() | |
| 10 | tfm.exec.disableAutoNewGame(true) | |
| 11 | tfm.exec.disableAutoShaman(true) | |
| 12 | tfm.exec.disableAutoTimeLeft(true) | |
| 13 | tfm.exec.disableAutoScore(true) | |
| 14 | tfm.exec.newGame(6159011) | |
| 15 | tfm.exec.setUIMapName("<CH><B>Rain</B> <N>| <CH>Highscore : <VP>"..highscore.." secs <N>Time : <V>00:00\n")
| |
| 16 | end | |
| 17 | ||
| 18 | function eventLoop(time) | |
| 19 | timer = timer + 0.5 | |
| 20 | if time>3000 and not ending then | |
| 21 | difficulty = math.ceil(timer/15) | |
| 22 | spawnArrow(difficulty) | |
| 23 | end | |
| 24 | if timer%1==0 then | |
| 25 | showTime(timer) | |
| 26 | end | |
| 27 | if ending then | |
| 28 | countdown = countdown - 1 | |
| 29 | tfm.exec.setUIMapName("<ROSE>The next game starts in "..countdown.."\n")
| |
| 30 | if countdown == 0 then | |
| 31 | tfm.exec.newGame(6159011) | |
| 32 | end | |
| 33 | end | |
| 34 | end | |
| 35 | ||
| 36 | function showTime(timer) | |
| 37 | local amount = timer / 60 | |
| 38 | local mins = math.floor(amount) | |
| 39 | local seconds = math.floor((amount - mins)*60) | |
| 40 | if mins < 10 then | |
| 41 | mins = "0"..tostring(mins) | |
| 42 | end | |
| 43 | if seconds < 10 then | |
| 44 | seconds = "0"..tostring(seconds) | |
| 45 | end | |
| 46 | tfm.exec.setUIMapName("<CH><B>Rain</B> <N>| <CH>Highscore : <VP>"..highscore.." secs <N>Time : <V>"..mins..":"..seconds.."\n")
| |
| 47 | end | |
| 48 | ||
| 49 | function eventNewGame() | |
| 50 | ui.removeTextArea(1) | |
| 51 | choosePlayer() | |
| 52 | difficulty = 1 | |
| 53 | tfm.exec.setUIMapName("<CH><B>Rain</B> <N>| <CH>Highscore : <VP>"..highscore.." secs <N>Time : <V>00:00\n")
| |
| 54 | timer=0 | |
| 55 | countdown=6 | |
| 56 | ending = false | |
| 57 | for k,v in pairs(tfm.get.room.playerList) do | |
| 58 | if k~=player then | |
| 59 | tfm.exec.killPlayer(k) | |
| 60 | end | |
| 61 | end | |
| 62 | end | |
| 63 | ||
| 64 | function eventPlayerDied(name) | |
| 65 | if name == player then | |
| 66 | ending = true | |
| 67 | ui.addTextArea(1, "<V><p align='center'><font size='12'><B>"..player.."</B><J> survived for <VP>".. math.floor(timer) .. " <J>seconds!", nil, 250, 23, 300, nil, 0x000001, nil, 0.8) | |
| 68 | if timer > highscore then | |
| 69 | - | highscore = math.ceil(timer) |
| 69 | + | highscore = math.floor(timer) |
| 70 | end | |
| 71 | end | |
| 72 | end | |
| 73 | ||
| 74 | function spawnArrow(int) | |
| 75 | if int==1 then | |
| 76 | tfm.exec.addShamanObject(17, math.random()*800, -80) | |
| 77 | elseif int==2 then | |
| 78 | tfm.exec.addShamanObject(17, math.random()*800, -80, 180) | |
| 79 | else | |
| 80 | for i=1, int-2 do | |
| 81 | tfm.exec.addShamanObject(17, math.random()*800, -80, 180) | |
| 82 | end | |
| 83 | tfm.exec.addShamanObject(2, math.random()*800, -80) | |
| 84 | end | |
| 85 | end | |
| 86 | ||
| 87 | function choosePlayer() | |
| 88 | player = players[1] | |
| 89 | table.remove(players, 1) | |
| 90 | table.insert(players, player) | |
| 91 | end | |
| 92 | ||
| 93 | function eventNewPlayer(name) | |
| 94 | table.insert(players, name) | |
| 95 | end | |
| 96 | ||
| 97 | function eventPlayerLeft(name) | |
| 98 | table.delete(players, name) | |
| 99 | end | |
| 100 | ||
| 101 | function table.delete(tab, val) | |
| 102 | for k,v in pairs(tab) do | |
| 103 | if val == v then | |
| 104 | table.remove(tab, k) | |
| 105 | break end | |
| 106 | end | |
| 107 | end | |
| 108 | ||
| 109 | for k,v in pairs(tfm.get.room.playerList) do | |
| 110 | eventNewPlayer(k) | |
| 111 | end | |
| 112 | ||
| 113 | main() |