Advertisement
wassimevicw

Untitled

May 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. tfm.exec.disableAutoShaman()
  2. tfm.exec.disableAutoNewGame()
  3. tfm.exec.disableAutoTimeLeft()
  4. tfm.exec.disableAfkDeath()
  5.  
  6. local players = {}
  7. local otype = tfm.enum.shamanObject.balloonFish
  8.  
  9. local function turnPufferFish(name)
  10. for i = 0, 3 do system.bindKeyboard(name, i, true) end
  11.  
  12. local px = tfm.get.room.playerList[name].x
  13. local py = tfm.get.room.playerList[name].y
  14.  
  15. tfm.exec.killPlayer(name)
  16.  
  17. players[name].pf = tfm.exec.addShamanObject(otype, px, py)
  18. end
  19.  
  20. function eventNewGame()
  21. ui.setMapName("Puffer fish!")
  22. for name in pairs(tfm.get.room.playerList) do
  23. local id = players[name] and players[name].pf or 0
  24. players[name] = {pf = nil, out = false}
  25. ui.removeTextArea(id, nil)
  26. turnPufferFish(name)
  27. end
  28. end
  29.  
  30. function eventNewPlayer(name)
  31. if players[name] then
  32. players[name].out = false
  33. else
  34. players[name] = {pf = nil, out = false}
  35. end
  36.  
  37. tfm.exec.respawnPlayer(name)
  38. turnPufferFish(name)
  39. end
  40.  
  41. function eventPlayerLeft(name)
  42. players[name].out = true
  43. tfm.exec.removeObject(players[name].pf)
  44. end
  45.  
  46. function eventKeyboard(name, key, down, x, y)
  47. local moves = {[0] = -30, [1] = -20, [2] = 30, [3] = 20}
  48.  
  49. if key == 0 or key == 2 then
  50. tfm.exec.moveObject(players[name].pf, 0, 0, true, moves[key])
  51. elseif key == 1 or key == 3 then
  52. tfm.exec.moveObject(players[name].pf, 0, 0, false, 0, moves[key], true)
  53. end
  54. end
  55.  
  56. function eventLoop(elapsed, remaining)
  57. for name in pairs(players) do
  58. local oid = players[name].pf
  59.  
  60. if not players[name].out then
  61. if tfm.get.room.objectList[oid] then
  62. local ox = tfm.get.room.objectList[oid].x
  63. local oy = tfm.get.room.objectList[oid].y
  64.  
  65. if oy > 390 or ox > 820 or ox < -20 then
  66. ui.removeTextArea(oid)
  67. players[name].pf = tfm.exec.addShamanObject(33, 400, 200)
  68. oid = players[name].pf
  69. ox, oy = 400, 200
  70. end
  71.  
  72. ui.addTextArea(oid, "<p align=\"center\">"..name.."</p>", nil, ox - 50, oy - 40, 100, nil, 0x1, 0x1, 0.8)
  73. end
  74. else
  75. ui.removeTextArea(oid, nil)
  76. end
  77. end
  78. end
  79.  
  80. tfm.exec.newGame(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement