Advertisement
Damian97

TPT lua sing bombs

Nov 7th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.68 KB | None | 0 0
  1. --
  2. tpt.set_console(0)
  3. local wn = 100
  4. local hn = 61
  5. local weapon = 0
  6. local strike = Window:new((sim.XRES - wn)/2, (sim.YRES - hn)/2, wn, hn)
  7. local bomber = Button:new(0, 0, 100, 16, "Bomber")
  8. local rocket = Button:new(0, 15, 100, 16, "Rocket strike")
  9. local orbital = Button:new(0, 30, 100, 16, "Orbital strike")
  10. local bomb = Button:new(0,45,100,16,"Explosion")
  11. --
  12. bomber:action(function() weapon = 1 interface.closeWindow(strike) end)
  13. rocket:action(function() weapon = 2 interface.closeWindow(strike) end)
  14. orbital:action(function() weapon = 3 interface.closeWindow(strike) end)
  15. bomb:action(function() weapon = 4 interface.closeWindow(strike) end)
  16. strike:onTryExit(function() interface.closeWindow(strike) end)
  17. --
  18. strike:addComponent(bomber)
  19. strike:addComponent(rocket)
  20. strike:addComponent(orbital)
  21. strike:addComponent(bomb)
  22. --
  23. local y
  24. local cur_pos_y
  25. local timer = 0
  26. local timer2 = 0
  27. local b = 0
  28. local fly = 0
  29. local cycle = 0
  30. local start_x = 4
  31. local x = start_x
  32. local end_x = 607
  33. local shoot_x
  34. local shoot_y
  35.  
  36. local function fastbomb()
  37. tpt.delete(shoot_x, shoot_y)
  38. tpt.create(shoot_x, shoot_y, "sing")
  39. tpt.set_property("life", 0, shoot_x, shoot_y)
  40. tpt.set_property("tmp", -500, shoot_x, shoot_y)
  41. b = 0
  42. tpt.unregister_step(fastbomb)
  43. end
  44.  
  45. local function orbitalbomb()
  46. if cur_pos_y == shoot_y then
  47. tpt.delete(shoot_x, cur_pos_y)
  48. tpt.create(shoot_x, cur_pos_y, "sing")
  49. tpt.set_property("life", 0, shoot_x, cur_pos_y)
  50. tpt.set_property("tmp", -500, shoot_x, cur_pos_y)
  51. b = 0
  52. cur_pos_y = y - 1
  53. if fly == 0 then
  54. tpt.register_step(check)
  55. end
  56. tpt.unregister_step(orbitalbomb)
  57. else
  58. while cur_pos_y ~= shoot_y do
  59. tpt.create(shoot_x, cur_pos_y, "bray")
  60. cur_pos_y = cur_pos_y + 1
  61. end
  62. end
  63. end
  64.  
  65. local function bomb()
  66. if timer2 < socket.gettime() then
  67. if cur_pos_y == shoot_y then
  68. tpt.delete(shoot_x, cur_pos_y)
  69. tpt.create(shoot_x, cur_pos_y, "sing")
  70. tpt.set_property("life", 0, shoot_x, cur_pos_y)
  71. tpt.set_property("tmp", -500, shoot_x, cur_pos_y)
  72. b = 0
  73. cur_pos_y = y - 1
  74. if fly == 0 then
  75. tpt.register_step(check)
  76. end
  77. tpt.unregister_step(bomb)
  78. else
  79. tpt.set_pause(0)
  80. tpt.set_console(0)
  81. tpt.create(shoot_x, cur_pos_y, "bray")
  82. cur_pos_y = cur_pos_y + 1
  83. timer2 = socket.gettime()+.0001
  84. end
  85. end
  86. end
  87.  
  88. local function move()
  89.     if timer < socket.gettime() then
  90.         cycle = cycle + 1
  91.         if cycle == 605 then
  92.         fly = 0
  93.         x = start_x
  94.         tpt.unregister_step(move)
  95.         if fly == 0 then
  96.         tpt.register_step(check)
  97.         end
  98.         else
  99.         tpt.set_pause(0)
  100.         tpt.set_console(0)
  101.         tpt.delete(x, y - 1)
  102.         tpt.delete(x, y)
  103.         tpt.delete(x + 1, y)
  104.         tpt.delete(x + 2, y)
  105.         tpt.delete(x + 2, y + 1)
  106.         tpt.delete(x + 3, y)
  107.         x = x + 1
  108.         tpt.create(x, y - 1, "DMND")
  109.         tpt.create(x, y, "DMND")
  110.         tpt.create(x + 1, y, "DMND")
  111.         tpt.create(x + 2, y, "DMND")
  112.         tpt.create(x + 2, y + 1, "DMND")
  113.         tpt.create(x + 3, y, "DMND")
  114.         tpt.set_property("dcolor", 0xFF404060, x, y - 1)
  115.         tpt.set_property("dcolor", 0xFF404060,x, y)
  116.         tpt.set_property("dcolor", 0xFF404060,x + 1, y)
  117.         tpt.set_property("dcolor", 0xFF404060,x + 2, y)
  118.         tpt.set_property("dcolor", 0xFF404060,x + 2, y + 1)
  119.         tpt.set_property("dcolor", 0xFF404060,x + 3, y)
  120.         if x + 1 == shoot_x then
  121.         tpt.register_step(bomb)
  122.         timer2 = socket.gettime()+.0001
  123.         end
  124.         timer = socket.gettime()+.0001
  125.         end
  126.     end
  127. end
  128. local function keycheck(char, code, modifiers, event)
  129.     if event == 1 and char == 'j' and b == 0 and fly == 0 and bit.band(modifiers, 0x3) == 0 then
  130.         shoot_x, shoot_y = sim.adjustCoords(tpt.mousex, tpt.mousey)
  131.         if weapon == 1 then
  132.         y = 70
  133.         cur_pos_y = y - 1
  134.         if shoot_y < y then
  135.         shoot_y = y + 1
  136.         end
  137.         tpt.create(x, y - 1, "DMND")
  138.         tpt.create(x, y, "DMND")
  139.         tpt.create(x + 1, y, "DMND")
  140.         tpt.create(x + 2, y, "DMND")
  141.         tpt.create(x + 2, y + 1, "DMND")
  142.         tpt.create(x + 3, y, "DMND")
  143.         fly = 1
  144.         tpt.set_property("dcolor", 0xFF404060, x, y - 1)
  145.         tpt.set_property("dcolor", 0xFF404060,x, y)
  146.         tpt.set_property("dcolor", 0xFF404060,x + 1, y)
  147.         tpt.set_property("dcolor", 0xFF404060,x + 2, y)
  148.         tpt.set_property("dcolor", 0xFF404060,x + 2, y + 1)
  149.         tpt.set_property("dcolor", 0xFF404060,x + 3, y)
  150.         timer = socket.gettime()+.05
  151.         cycle = 0
  152.         tpt.register_step(move)
  153.         tpt.unregister_step(check)
  154.        
  155.         elseif weapon == 2 then
  156.         y = 0
  157.         cur_pos_y = y - 1
  158.         tpt.register_step(bomb)
  159.         timer2 = socket.gettime()+.0001
  160.        
  161.         elseif weapon == 3 then
  162.         y = 0
  163.         cur_pos_y = y - 1
  164.         tpt.register_step(orbitalbomb)
  165.         timer2 = socket.gettime()+.0001
  166.        
  167.         elseif weapon == 4 then
  168.         tpt.register_step(fastbomb)
  169.         end
  170.         b = 1
  171.     elseif event == 1 and char == 'j' and bit.band(modifiers, 0x3) ~= 0 then
  172.     interface.showWindow(strike)
  173.     end
  174.     end
  175.  
  176. function check()
  177. tpt.register_keypress(keycheck)
  178. end
  179. tpt.register_step(check)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement