Formated Paste

  1. debug.disableEventLog(true)
  2. tfm.exec.disableAutoNewGame(true)
  3. tfm.exec.disableAutoTimeLeft(true)
  4. tfm.exec.disableAutoScore(true)
  5. tfm.exec.disableAutoShaman(true)
  6. TICKS = 10;
  7.  
  8. local s = 1000/TICKS;
  9. for t = 0, 1000 - s, s do
  10. system.newTimer(function () system.newTimer(loop, 1000, true) end, 1000 + t, false);
  11. end
  12.  
  13. function newRound()
  14. tfm.exec.newGame(2876844)
  15. players={}
  16. fights={}
  17. spawns={}
  18. runes={}
  19. runestime={}
  20. runesshot={}
  21. canShoot={}
  22. fightsalive = 0
  23. spawnsalive = 0
  24. end
  25.  
  26. function eventNewGame()
  27. for name,player in pairs(tfm.get.room.playerList) do
  28. table.insert(players,player)
  29. bindKeys(name, true)
  30. end
  31. for i=1,#players,1 do
  32. local index=math.random(#players)
  33. local player=players[index]
  34. if i%3==0 then
  35. table.insert(fights,player.playerName)
  36. --tfm.exec.chatMessage("<R>"..player.playerName)
  37. tfm.exec.movePlayer(player.playerName,1380,215)
  38. tfm.exec.setNameColor(player.playerName,0xc13535)
  39. fightsalive = fightsalive + 1
  40. elseif i%2==0 then
  41. table.insert(spawns,player.playerName)
  42. --tfm.exec.chatMessage("<BV>"..player.playerName)
  43. tfm.exec.movePlayer(player.playerName,140,345)
  44. tfm.exec.setNameColor(player.playerName,0x354fc1)
  45. canShoot[player.playerName]=true
  46. spawnsalive = spawnsalive + 1
  47. else
  48. table.insert(fights,player.playerName)
  49. --tfm.exec.chatMessage("<R>"..player.playerName)
  50. tfm.exec.movePlayer(player.playerName,1380,215)
  51. tfm.exec.setNameColor(player.playerName,0xc13535)
  52. fightsalive = fightsalive + 1
  53. end
  54. table.remove(players,index)
  55. end
  56. end
  57.  
  58. function eventLoop(time,remaining)
  59. if remaining<=0 or fightsalive<=0 or spawnsalive<=0 then
  60. newRound()
  61. end
  62. end
  63.  
  64. function loop()
  65. for k,v in pairs(runestime) do
  66. if v~=0 and (tonumber(os.time())>v+5000) then
  67. tfm.exec.removeObject(runes[k])
  68. canShoot[runesshot[k]] = true
  69. --runestime[v] = 0
  70. table.remove(runestime,k)
  71. table.remove(runes,k)
  72. table.remove(runesshot,k)
  73. break
  74. end
  75. end
  76. end
  77.  
  78. function eventPlayerLeft(playerName)
  79. bindKeys(playerName, false)
  80. end
  81.  
  82. function bindKeys(playerName, active)
  83. tfm.exec.bindKeyboard(playerName,83,active,true) -- S
  84. tfm.exec.bindKeyboard(playerName,40,active,true) -- DOWN
  85. end
  86.  
  87. function eventKeyboard(playerName, key, down, x, y)
  88. if (key==83 or key==40) and inTable(spawns,playerName) and canShoot[playerName]==true then
  89. rune=tfm.exec.addShamanObject(62,x+25,y,0,0,0,true)
  90. table.insert(runes,rune)
  91. table.insert(runestime,os.time())
  92. table.insert(runesshot,playerName)
  93. canShoot[playerName]=false
  94. end
  95. end
  96.  
  97. function eventPlayerDied(playerName)
  98. if inTable(fights,playerName) then
  99. fightsalive = fightsalive - 1
  100. end
  101. if inTable(spawns,playerName) then
  102. spawnsalive = spawnsalive - 1
  103. end
  104. end
  105.  
  106. function eventPlayerWon(playerName)
  107. if inTable(fights,playerName) then
  108. fightsalive = fightsalive - 1
  109. end
  110. if inTable(spawns,playerName) then
  111. fightsalive = fightsalive - 1
  112. end
  113. end
  114.  
  115. function tfm.exec.giveWinAll()
  116. for playerName,player in pairs(tfm.get.room.playerList) do
  117. if not player.isDead then
  118. tfm.exec.giveCheese(playerName)
  119. tfm.exec.playerVictory(playerName)
  120. end
  121. end
  122. end
  123.  
  124. function inTable(tbl, item)
  125. for key, value in pairs(tbl) do
  126. if value == item then
  127. return key
  128. end
  129. end
  130. return false
  131. end
  132.  
  133. newRound()
Name:
Email:
Code/text to paste:
  • Enable code highlighting
  • Code Language:
  • What software do we use to power the pastebin?: