Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tfm.exec.disableAutoShaman()
- tfm.exec.disableAutoNewGame()
- tfm.exec.disableAutoTimeLeft()
- game = {}
- game.maps = {6697343,7097916,6775837,7155011,7186973}
- game.canStart = false
- game.isStarted = false
- game.isFinished = false
- game.potato = nil
- game.explosionTime = 15
- game.currentTime = game.explosionTime * 2
- game.playerCount = 0
- game.isRoom = tfm.get.room.name:sub(1,2):find("#") and true or false
- game.potatoImage = nil
- lang = {
- en = {
- ["minPlayers"] = "<R>É necessário pelo menos 2 jogadores :(",
- ["welcome"] = "<N>Bem-vindo ao batata feio para <B>guerras(wars)</B>/<B>x1</B>.",
- ["gotPotato"] = "<V>%s <BL>está com a batata!",
- ["finishedRound"] = "<BL>Acabou! <V>%s <BL>é o vencedor!",
- ["time"] = "<J>%s <BL>- %s | <N>Tempo : <V>%i segundos",
- ["help"] = "<BL><p align='center'><font size='26'>Ajuda</font></p><N><br>Batata quente é a clássica brincadeira de infância agora no Transformice!<br><br>O rato com mais pontos a cada mapa terá a batata!<br>O rato com a batata deve passá-la para outro rato apertando <J>ESPAÇO <N>perto dele.<br>Após 15 segundos o rato que estiver com a batata morrerá!<br>O útlimo a sobreviver ganhará a partida.<br><br>Desenvolvido por Laagaadoo.<br><BL><p align='center'><a href='event:closeHelp'>Fechar</a></p>"
- }
- }
- function game.setPotato(name)
- if not game.isFinished then
- if game.potato then
- tfm.exec.setNameColor(game.potato, 0)
- system.bindKeyboard(game.potato, 32, false, false)
- if game.isRoom then
- tfm.exec.removeImage(game.potatoImage)
- end
- end
- game.potato = name
- if game.isRoom then
- game.potatoImage = tfm.exec.addImage("155bc34f15d.png", "$"..name, 2, -6)
- end
- tfm.exec.setNameColor(name, 0xFFFF00)
- system.bindKeyboard(name, 32, true, true)
- sendMessage(translate("gotPotato"):format(name))
- end
- end
- function game.newGame()
- tfm.exec.newGame(game.maps[math.random(#game.maps)])
- tfm.exec.setGameTime(360)
- end
- function game.highScore()
- local hs, hsName = -1, nil
- for name, player in pairs(tfm.get.room.playerList) do
- if player.score > hs and not player.isDead then
- hs = player.score
- hsName = name
- end
- end
- return hsName
- end
- sendMessage = function(message, name)
- if game.isRoom then
- tfm.exec.chatMessage(message, name)
- else
- print(message)
- end
- end
- translate = function(message)
- return lang[tfm.get.room.community] and lang[tfm.get.room.community][message] or lang.en[message]
- end
- eventNewGame = function()
- game.isStarted = false
- game.isFinished = false
- game.currentTime = game.explosionTime * 2
- end
- eventNewPlayer = function(name)
- game.playerCount = game.playerCount + 1
- ui.addTextArea(0, "", name, 6, 29, 20, 20, 0x5b3c27, 0x5b3c27, 1, true)
- ui.addTextArea(1, "", name, 7, 30, 20, 20, 0x241c15, 0x241c15, 1, true)
- ui.addTextArea(2, "<p align='center'><font size='12'><a href='event:showHelp'>?</a></font></p>", name, 7, 30, 19, 19, 0x3e2c1f, 0x3e2c1f, 1, true)
- if game.playerCount > 1 then
- game.canStart = true
- end
- if game.isRoom then
- sendMessage(translate("welcome"), name)
- tfm.exec.lowerSyncDelay(name)
- end
- end
- eventPlayerLeft = function(name)
- game.playerCount = game.playerCount - 1
- if game.playerCount < 2 then
- game.canStart = false
- end
- end
- eventTextAreaCallback = function(id, name, callback)
- if callback == "showHelp" then
- ui.addTextArea(3, translate("help"), name, 233.5, 86, 333, 228, 0x3e2c1f, 0x3e2c1f, 1, true)
- elseif callback == "closeHelp" then
- ui.removeTextArea(id, name)
- end
- end
- eventKeyboard = function(name, key, down, x, y)
- if key == 32 then
- if name == game.potato then
- for target, player in pairs(tfm.get.room.playerList) do
- if (target ~= name) and not player.isDead then
- if x >= player.x - 15 and x <= player.x + 15 and y >= player.y - 15 and y <= player.y + 15 then
- game.setPotato(target)
- break
- end
- end
- end
- end
- end
- end
- eventPlayerDied = function(name)
- if name == game.potato and not game.isFinished then
- game.setPotato(game.highScore())
- end
- end
- eventLoop = function(current, remaining)
- if game.canStart then
- if game.isStarted then
- local alive, namesAlive = 0, {}
- for name, player in pairs(tfm.get.room.playerList) do
- if not player.isDead then
- alive = alive + 1
- namesAlive[#namesAlive+1] = name
- end
- end
- if alive == 1 then
- game.isFinished = true
- tfm.exec.giveCheese(namesAlive[1])
- tfm.exec.playerVictory(namesAlive[1])
- tfm.exec.setGameTime(6)
- sendMessage(translate("finishedRound"):format(namesAlive[1]))
- end
- if remaining <= 0 then game.newGame() end
- if not game.isFinished then
- ui.addTextArea(10, "<p align=\"center\"><font size=\"25\"><J><B>".. math.floor(game.currentTime/2) .." (tfm.get.room.xmlMapInfo.author, tfm.get.room.currentMap, math.floor(game.currentTime/2)", nil, 376, 355, 46, 39, 0x000001, 0x000000, 0.8, true)
- game.currentTime = game.currentTime - 1
- local particles = {2, 13}
- for i = 1, 2 do
- tfm.exec.displayParticle(particles[math.random(#particles)], tfm.get.room.playerList[game.potato].x, tfm.get.room.playerList[game.potato].y - math.random(5, 15), math.random(-1, 1), math.random(-1, 1))
- end
- if game.currentTime == 0 then
- if alive == 2 then
- game.currentTime = game.explosionTime * 2
- tfm.exec.killPlayer(game.potato)
- local i = 1
- while(game.potato == namesAlive[i]) do
- i = i + 1
- end
- game.isFinished = true
- tfm.exec.giveCheese(namesAlive[i])
- tfm.exec.playerVictory(namesAlive[i])
- tfm.exec.setGameTime(6)
- sendMessage(translate("finishedRound"):format(namesAlive[i]))
- else
- game.currentTime = game.explosionTime * 2
- tfm.exec.killPlayer(game.potato)
- end
- end
- end
- else
- if current >= 5000 then
- game.setPotato(game.highScore())
- game.isStarted = true
- tfm.exec.setPlayerScore(game.potato, 0)
- end
- end
- end
- end
- for name in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- tfm.exec.setPlayerScore(name, 0)
- end
- if game.canStart then
- game.newGame()
- else
- sendMessage(translate("minPlayers"))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement