Created
September 12, 2016 19:00
-
-
Save Patosito/cab972d99a3da67917ce23adff6261a9 to your computer and use it in GitHub Desktop.
Rotación simple de mapas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local maps = {1810386,1864223,1729924,2372033,1700658,1484328,2706423,1738989,3295997} | |
local currentMap | |
local playersAlive | |
function main() | |
tfm.exec.disableAutoNewGame(true) | |
startGame() | |
end | |
function startGame() | |
local newMap | |
repeat | |
newMap = math.random(#maps) | |
until newMap ~= currentMap | |
currentMap = newMap | |
tfm.exec.newGame(maps[newMap]) | |
end | |
function endGame() | |
startGame() | |
end | |
function eventNewGame() | |
playersAlive = 0 | |
for _ in pairs(tfm.get.room.playerList) do | |
playersAlive = playersAlive + 1 | |
end | |
end | |
function eventPlayerRespawn(name) | |
playersAlive = playersAlive + 1 | |
end | |
function eventPlayerDied(name) | |
playersAlive = playersAlive - 1 | |
checkPlayers() | |
end | |
function eventPlayerWon(name) | |
playersAlive = playersAlive - 1 | |
checkPlayers() | |
end | |
function checkPlayers() | |
if playersAlive == 0 then | |
endGame() | |
end | |
end | |
function eventLoop(t, tr) | |
if tr <= 0 then | |
endGame() | |
end | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment