Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function f(txt) -- just for readability
- return string.format([[<font color="#89A7F5">%s</font>]], txt)
- end
- local welcome = string.format("<N>Hello there! %s is an unofficial minigame that can currently only be played in the tribe house. Please support %s!", f("#Iced"), f("#Iced"))
- print(welcome) -- why though?
- maps = { 4446887 }
- players = {}
- function getMouseCount()
- local count = 0
- for p in pairs(tfm.get.room.playerList) do
- if not tfm.get.room.playerList[p].isDead or players[p].id then
- count = count + 1
- end
- end
- return count
- end
- function eventLoop(time,remaining)
- local n = getMouseCount()
- if remaining <= 0 or n == 0 then
- newRound()
- end
- end
- function newRound()
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- function eventNewGame()
- tfm.exec.snow()
- tfm.exec.setUIMapName(string.format("<N>Welcome to %s! Press %s to turn into an Ice Cube! Press %s to turn into an Ice Plank! Have fun! \n", f("#Iced"), f("Z"), f("X")))
- for player in pairs(tfm.get.room.playerList) do
- if player.isIced then
- player.isIced = false
- end
- end
- end
- function eventNewPlayer(name)
- ui.addTextArea(1, string.format("<p align='center'><b>%s</b></p>", welcome), name, 5, 25, 790, 25, nil, nil, 0)
- tfm.exec.bindKeyboard(name, 87, true, true)
- tfm.exec.bindKeyboard(name, 88, true, true)
- players[name] = { timestamp = os.time(), isIced = false }
- end
- function eventKeyboard(name,key,down,x,y)
- local p = players[name]
- if p.timestamp < os.time() - 800 then
- if not p.isIced then
- p.isIced = true -- player is now iced.
- tfm.exec.movePlayer(name, 400, -520, false, 0, 0, false) -- For avoid dead spamming.
- local id = tfm.exec.addShamanObject((key == 87 and 54 or 45), x, y)
- p.id = id
- elseif p.id then
- local x_ = tfm.get.room.objectList[p.id].x
- if x_ == 0 then
- tfm.exec.killPlayer(name)
- else
- p.isIced = false
- tfm.exec.movePlayer(name, x_, tfm.get.room.objectList[p.id].y)
- end
- tfm.exec.removeObject(p.id)
- p.id = nil
- end
- p.timestamp = os.time()
- end
- end
- function main()
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.newGame(maps[math.random(#maps)])
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- end
- main()
- function eventPlayerWon(name)
- players[name].id = nil
- end
- function eventPlayerGetCheese(name)
- tfm.exec.playerVictory(name)
- end
- function eventChatCommand(name, command)
- if command == "np" then
- tfm.exec.newGame(maps[math.random(#maps)])
- elseif command == "die" or command == "mort" or command == "kill" then
- tfm.exec.killPlayer(name)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment