Skip to content

Instantly share code, notes, and snippets.

@Patosito
Created September 12, 2016 19:00
Show Gist options
  • Save Patosito/cab972d99a3da67917ce23adff6261a9 to your computer and use it in GitHub Desktop.
Save Patosito/cab972d99a3da67917ce23adff6261a9 to your computer and use it in GitHub Desktop.
Rotación simple de mapas
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