Advertisement
Travonrodfer

Emoção e objetos

Aug 19th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. tfm.exec.disableAutoNewGame(true)
  2. tfm.exec.disableAutoShaman(true)
  3. players={}
  4. toDespawn={}
  5.  
  6. function eventNewPlayer(name)
  7. for i,key in ipairs({48,49,50,51,52,53,54,55,56,57}) do
  8. tfm.exec.bindKeyboard(name,key,true,true)
  9. end
  10. players[name]={
  11. timestamp=os.time(),
  12. offsets={x=2, y=10}
  13. }
  14. end
  15.  
  16. function eventKeyboard(name,key,down,x,y)
  17. if (key == 48) and not tfm.get.room.playerList[name].isDead and started then
  18. if players[name].timestamp < os.time()-500 then
  19. local id=tfm.exec.addShamanObject(103, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  20. players[name].timestamp=os.time()
  21. table.insert(toDespawn,{os.time(),id})
  22. end
  23. end
  24.  
  25. if (key == 49) and not tfm.get.room.playerList[name].isDead and started then
  26. if players[name].timestamp < os.time()-500 then
  27. local id=tfm.exec.addShamanObject(403, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  28. players[name].timestamp=os.time()
  29. table.insert(toDespawn,{os.time(),id})
  30. end
  31. end
  32.  
  33. if (key == 50) and not tfm.get.room.playerList[name].isDead and started then
  34. if players[name].timestamp < os.time()-500 then
  35. local id=tfm.exec.addShamanObject(206, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  36. players[name].timestamp=os.time()
  37. table.insert(toDespawn,{os.time(),id})
  38. end
  39. end
  40.  
  41. if (key == 51) and not tfm.get.room.playerList[name].isDead and started then
  42. if players[name].timestamp < os.time()-500 then
  43. local id=tfm.exec.addShamanObject(1003, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  44. players[name].timestamp=os.time()
  45. table.insert(toDespawn,{os.time(),id})
  46. end
  47. end
  48.  
  49. if (key == 52) and not tfm.get.room.playerList[name].isDead and started then
  50. if players[name].timestamp < os.time()-500 then
  51. local id=tfm.exec.addShamanObject(6, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  52. players[name].timestamp=os.time()
  53. table.insert(toDespawn,{os.time(),id})
  54. end
  55. end
  56.  
  57. if (key == 53) and not tfm.get.room.playerList[name].isDead and started then
  58. if players[name].timestamp < os.time()-500 then
  59. local id=tfm.exec.addShamanObject(2810, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  60. players[name].timestamp=os.time()
  61. table.insert(toDespawn,{os.time(),id})
  62. end
  63. end
  64.  
  65. if (key == 54) and not tfm.get.room.playerList[name].isDead and started then
  66. if players[name].timestamp < os.time()-500 then
  67. local id=tfm.exec.addShamanObject(57, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 100 or -100)
  68. players[name].timestamp=os.time()
  69. table.insert(toDespawn,{os.time(),id})
  70. end
  71. end
  72.  
  73. if (key == 55) and not tfm.get.room.playerList[name].isDead and started then
  74. if players[name].timestamp < os.time()-500 then
  75. local id=tfm.exec.addShamanObject(59, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  76. players[name].timestamp=os.time()
  77. table.insert(toDespawn,{os.time(),id})
  78. end
  79. end
  80.  
  81. if (key == 56) and not tfm.get.room.playerList[name].isDead and started then
  82. if players[name].timestamp < os.time()-500 then
  83. local id=tfm.exec.addShamanObject(39, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  84. players[name].timestamp=os.time()
  85. table.insert(toDespawn,{os.time(),id})
  86. end
  87. end
  88. if (key == 57) and not tfm.get.room.playerList[name].isDead and started then
  89. if players[name].timestamp < os.time()-500 then
  90. local id=tfm.exec.addShamanObject(46, x+(tfm.get.room.playerList[name].isFacingRight and players[name].offsets.x or -players[name].offsets.x), y+players[name].offsets.y, 0, tfm.get.room.playerList[name].isFacingRight and 20 or -20)
  91. players[name].timestamp=os.time()
  92. table.insert(toDespawn,{os.time(),id})
  93. end
  94. end
  95. end
  96.  
  97. function eventChatCommand(name,command)
  98. local arg={}
  99. for argument in command:gmatch("[^%s]+") do
  100. table.insert(arg,argument)
  101. end
  102. if arg[1]=="off" then
  103. if tonumber(arg[2]) and tonumber(arg[3]) then
  104. players[name].offsets.x=tonumber(arg[2])
  105. players[name].offsets.y=tonumber(arg[3])
  106. else
  107. players[name].offsets.x=2
  108. players[name].offsets.y=10
  109. end
  110. tfm.exec.chatMessage("Offsets changed to X:"..players[name].offsets.x.." Y:"..players[name].offsets.y,name)
  111. end
  112. end
  113.  
  114. function eventNewGame()
  115. started=false
  116. end
  117.  
  118. function eventLoop(time,remaining)
  119. if time >= 1000 and not started then
  120. started=true
  121. end
  122. for i,cannon in ipairs(toDespawn) do
  123. if cannon[1] <= os.time()-3000 then
  124. tfm.exec.removeObject(cannon[2])
  125. table.remove(toDespawn,i)
  126. end
  127. end
  128. end
  129.  
  130. for name,player in pairs(tfm.get.room.playerList) do
  131. eventNewPlayer(name)
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement