Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local data = {
- players = {},
- currentshaman = '',
- }
- for k, v in next, {'AutoShaman', 'AutoTimeLeft', 'AutoNewGame', 'AfkDeath'} do
- tfm.exec['disable' .. v]()
- end
- tfm.exec.newGame('#4')
- function eventNewPlayer(name)
- data.players[name] = {
- rounds = 0,
- savedmice = 0,
- deadmice = 0,
- death = 0,
- nails = 0
- }
- for k, v in next, {66, 67, 74, 78, 80, 86} do
- system.bindKeyboard(name, v, true)
- end
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- function eventNewGame()
- local players = {}
- for k, v in next, data.players do
- players[#players + 1] = k
- end
- if (data.currentshaman ~= '') then
- local shaman = data.currentshaman
- repeat
- data.currentshaman = players[math.random(#players)]
- until
- shaman ~= data.currentshaman
- else
- data.currentshaman = players[math.random(#players)]
- end
- tfm.exec.setShaman(data.currentshaman)
- ui.setShamanName(data.currentshaman)
- data.players[data.currentshaman].nails = 0
- data.players[data.currentshaman].rounds = data.players[data.currentshaman].rounds + 1
- end
- function eventKeyboard(name, key)
- if (not tfm.get.room.playerList[name].isDead and data.currentshaman == name) then
- if (key == 66 or key == 67 or key == 74 or key == 78 or key == 86) then
- data.players[name].nails = data.players[name].nails + 1
- if (data.players[name].nails > 4) then
- tfm.exec.killPlayer(name)
- ui.addPopup(1, 0, 'You died trying to use nails. <v>(' .. data.players[name].nails .. '/5)', name, 270, 170, 250)
- else
- ui.addPopup(1, 0, "You can't use nails! <v>(" .. data.players[name].nails .. "/5)", name, 300, 170)
- end
- end
- end
- end
- function eventSummoningEnd(name, obj, x, y, angle, table)
- tfm.exec.removeObject(table.id)
- tfm.exec.addShamanObject(obj, x, y, angle, table.vx, table.vy, table.ghost)
- end
- function eventLoop(elapsed, remaining)
- local remaining = math.floor(remaining/1000)
- if (remaining <= 0) then
- tfm.exec.newGame('#4')
- end
- end
- function eventPlayerDied(name)
- if (data.currentshaman == name) then
- data.players[data.currentshaman].death = data.players[data.currentshaman].death + 1
- tfm.exec.setGameTime(5, false)
- else
- data.players[data.currentshaman].deadmice = data.players[data.currentshaman].deadmice + 1
- local a = 0
- for k, v in next, tfm.get.room.playerList do
- if (not v.isDead) then
- a = a + 1
- end
- end
- if (a <= 1) then
- tfm.exec.setGameTime(5, false)
- end
- end
- end
- function eventPlayerWon(name)
- if (data.currentshaman ~= name) then
- data.players[data.currentshaman].savedmice = data.players[data.currentshaman].savedmice + 1
- local a = 0
- for k, v in next, tfm.get.room.playerList do
- if (not v.isDead) then
- a = a + 1
- end
- end
- if (a <= 1) then
- tfm.exec.setGameTime(5, false)
- end
- else
- tfm.exec.setGameTime(5, false)
- end
- end
- function string.split(str,s)
- local res = {}
- for part in string.gmatch(str, "[^" .. s .. "]+") do
- table.insert(res, part)
- end
- return res
- end
- function showProfile(name, shaman)
- local rounds = data.players[shaman].rounds
- local saved, dead = data.players[shaman].savedmice, data.players[shaman].deadmice
- local death = data.players[shaman].death
- local str = string.format("<font size='20'><p align='center'><V>%s</V></font><font size='14'>\n<J>Data</J></p>\n\nRounds : <V>%s</V>\nShaman : <J>%s</J><BL> / </BL><R>%s</R>\n\nDeaths : <V>%s\n\n\n", shaman, rounds, saved, dead, death)
- ui.addTextArea(0, str, name, 294, 113, 227, 175, 0x000001, 0x000000, 1, true)
- ui.addTextArea(1, "<p align='center'><B><R><a href='event:close'>X", name, 524, 113, 21, 18, 0x000001, 0x000000, 1, true)
- end
- function eventChatCommand(name, cmd)
- local cmd = string.split(cmd, ' ')
- if (cmd[1] == 'help' or cmd[1] == 'info') then
- ui.addPopup(0, 0, "Use your creativity and build WITHOUT nails! When you save mice, higher will be you score! Be careful, don't let any mice die.\nPress P or type !p [Player] to open a player's profile. Good luck!", name, 280, 120, 250)
- elseif (cmd[1] == 'p' or cmd[1] == 'perfil') then
- if (cmd[2]) then
- cmd[2] = cmd[2]:gsub('^%l', string.upper)
- if (tfm.get.room.playerList[cmd[2]]) then
- showProfile(name, cmd[2])
- end
- else
- showProfile(name, name)
- end
- end
- end
- function eventTextAreaCallback(id, name, link)
- if (link == 'close') then
- for i = 0, 1 do ui.removeTextArea(i, name) end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement