Advertisement
Guest User

[Script] No nails

a guest
Oct 18th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.37 KB | None | 0 0
  1. local data = {
  2.     players = {},
  3.     currentshaman = '',
  4. }
  5.  
  6. for k, v in next, {'AutoShaman', 'AutoTimeLeft', 'AutoNewGame', 'AfkDeath'} do
  7.     tfm.exec['disable' .. v]()
  8. end
  9.  
  10. tfm.exec.newGame('#4')
  11.  
  12. function eventNewPlayer(name)
  13.     data.players[name] = {
  14.         rounds = 0,
  15.         savedmice = 0,
  16.         deadmice = 0,
  17.         death = 0,
  18.         nails = 0
  19.     }
  20.  
  21.     for k, v in next, {66, 67, 74, 78, 80, 86} do
  22.         system.bindKeyboard(name, v, true)
  23.     end
  24. end
  25. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  26.  
  27. function eventNewGame()
  28.     local players = {}
  29.     for k, v in next, data.players do
  30.         players[#players + 1] = k
  31.     end
  32.  
  33.     if (data.currentshaman ~= '') then
  34.         local shaman = data.currentshaman
  35.         repeat
  36.             data.currentshaman = players[math.random(#players)]
  37.         until
  38.             shaman ~= data.currentshaman
  39.     else
  40.         data.currentshaman = players[math.random(#players)]
  41.     end
  42.     tfm.exec.setShaman(data.currentshaman)
  43.     ui.setShamanName(data.currentshaman)
  44.  
  45.     data.players[data.currentshaman].nails = 0
  46.     data.players[data.currentshaman].rounds = data.players[data.currentshaman].rounds + 1
  47. end
  48.  
  49. function eventKeyboard(name, key)
  50.     if (not tfm.get.room.playerList[name].isDead and data.currentshaman == name) then
  51.         if (key == 66 or key == 67 or key == 74 or key == 78 or key == 86) then
  52.             data.players[name].nails = data.players[name].nails + 1
  53.             if (data.players[name].nails > 4) then
  54.                 tfm.exec.killPlayer(name)
  55.                 ui.addPopup(1, 0, 'You died trying to use nails. <v>(' .. data.players[name].nails .. '/5)', name, 270, 170, 250)
  56.             else
  57.                 ui.addPopup(1, 0, "You can't use nails! <v>(" .. data.players[name].nails .. "/5)", name, 300, 170)
  58.             end
  59.         end
  60.     end
  61. end
  62.  
  63. function eventSummoningEnd(name, obj, x, y, angle, table)
  64.     tfm.exec.removeObject(table.id)
  65.  
  66.     tfm.exec.addShamanObject(obj, x, y, angle, table.vx, table.vy, table.ghost)
  67. end
  68.  
  69. function eventLoop(elapsed, remaining)
  70.     local remaining = math.floor(remaining/1000)
  71.  
  72.     if (remaining <= 0) then
  73.         tfm.exec.newGame('#4')
  74.     end
  75. end
  76.  
  77. function eventPlayerDied(name)
  78.     if (data.currentshaman == name) then
  79.         data.players[data.currentshaman].death = data.players[data.currentshaman].death + 1
  80.         tfm.exec.setGameTime(5, false)
  81.     else
  82.         data.players[data.currentshaman].deadmice = data.players[data.currentshaman].deadmice + 1
  83.  
  84.         local a = 0
  85.         for k, v in next, tfm.get.room.playerList do
  86.             if (not v.isDead) then
  87.                 a = a + 1
  88.             end
  89.         end
  90.         if (a <= 1) then
  91.             tfm.exec.setGameTime(5, false)
  92.         end
  93.     end
  94. end
  95.  
  96. function eventPlayerWon(name)
  97.     if (data.currentshaman ~= name) then
  98.         data.players[data.currentshaman].savedmice = data.players[data.currentshaman].savedmice + 1
  99.  
  100.         local a = 0
  101.         for k, v in next, tfm.get.room.playerList do
  102.             if (not v.isDead) then
  103.                 a = a + 1
  104.             end
  105.         end
  106.         if (a <= 1) then
  107.             tfm.exec.setGameTime(5, false)
  108.         end
  109.     else
  110.         tfm.exec.setGameTime(5, false)
  111.     end
  112. end
  113.  
  114. function string.split(str,s)
  115.     local res = {}
  116.     for part in string.gmatch(str, "[^" .. s .. "]+") do
  117.         table.insert(res, part)
  118.     end
  119.     return res
  120. end
  121.  
  122. function showProfile(name, shaman)
  123.     local rounds = data.players[shaman].rounds
  124.     local saved, dead = data.players[shaman].savedmice, data.players[shaman].deadmice
  125.     local death = data.players[shaman].death
  126.     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)
  127.  
  128.     ui.addTextArea(0, str, name, 294, 113, 227, 175, 0x000001, 0x000000, 1, true)
  129.     ui.addTextArea(1, "<p align='center'><B><R><a href='event:close'>X", name, 524, 113, 21, 18, 0x000001, 0x000000, 1, true)
  130. end
  131.  
  132. function eventChatCommand(name, cmd)
  133.     local cmd = string.split(cmd, ' ')
  134.     if (cmd[1] == 'help' or cmd[1] == 'info') then
  135.         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)
  136.     elseif (cmd[1] == 'p' or cmd[1] == 'perfil') then
  137.         if (cmd[2]) then
  138.             cmd[2] = cmd[2]:gsub('^%l', string.upper)
  139.             if (tfm.get.room.playerList[cmd[2]]) then
  140.                 showProfile(name, cmd[2])
  141.             end
  142.         else
  143.             showProfile(name, name)
  144.         end
  145.     end
  146. end
  147.  
  148. function eventTextAreaCallback(id, name, link)
  149.     if (link == 'close') then
  150.         for i = 0, 1 do ui.removeTextArea(i, name) end
  151.     end
  152. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement