Advertisement
roger109z

Untitled

Sep 5th, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. local modules = peripheral.find("neuralInterface")
  2. if not modules then
  3. error("Must have a neural interface", 0)
  4. end
  5. if not modules.hasModule("plethora:sensor") then error("Must have a sensor", 0) end
  6. if not modules.hasModule("plethora:scanner") then error("Must have a scanner", 0) end
  7. if not modules.hasModule("plethora:introspection") then error("Must have an introspection module", 0) end
  8. if not modules.hasModule("plethora:kinetic", 0) then error("Must have a kinetic agument", 0) end
  9. local meta = {}
  10. local hover = false
  11. parallel.waitForAny(
  12. function()
  13. while true do
  14. local event, key = os.pullEvent()
  15. if event == "key" and key == keys.o then
  16. -- The O key launches you high into the air.
  17. modules.launch(0, -90, 3)
  18. elseif event == "key" and key == keys.p then
  19. -- The P key launches you a little into the air.
  20. modules.launch(0, -90, 1)
  21. elseif event == "key" and key == keys.l then
  22. -- The l key launches you in whatever direction you are looking.
  23. modules.launch(meta.yaw, meta.pitch, 3)
  24. elseif event == "key" and key == keys.k then
  25. -- Holding the K key enables "hover" mode. We disable it when it is released.
  26. if not hover then
  27. hover = true
  28. os.queueEvent("hover")
  29. end
  30. elseif event == "key_up" and key == keys.k then
  31. hover = false
  32. end
  33. end
  34. end,
  35. function()
  36. while true do
  37. local event, key = os.pullEvent()
  38. if event == "key" and key == keys.o then
  39. -- The O key launches you high into the air.
  40. modules.launch(0, -90, 3)
  41. elseif event == "key" and key == keys.p then
  42. -- The P key launches you a little into the air.
  43. modules.launch(0, -90, 1)
  44. elseif event == "key" and key == keys.l then
  45. -- The l key launches you in whatever direction you are looking.
  46. modules.launch(meta.yaw, meta.pitch, 3)
  47. elseif event == "key" and key == keys.k then
  48. -- Holding the K key enables "hover" mode. We disable it when it is released.
  49. if not hover then
  50. hover = true
  51. os.queueEvent("hover")
  52. end
  53. elseif event == "key_up" and key == keys.k then
  54. hover = false
  55. end
  56. end
  57. end,
  58. function()
  59. while true do
  60. if hover then
  61. -- We calculate the required motion we need to take
  62. local mY = meta.motionY
  63. mY = (mY - 0.138) / 0.8
  64.  
  65. -- If it is sufficiently large then we fire ourselves in that direction.
  66. if mY > 0.5 or mY < 0 then
  67. local sign = 1
  68. if mY < 0 then sign = -1 end
  69. modules.launch(0, 90 * sign, math.min(4, math.abs(mY)))
  70. else
  71. sleep(0)
  72. end
  73. else
  74. os.pullEvent("hover")
  75. end
  76. end
  77. end,
  78. function()
  79. while true do
  80. local blocks = modules.scan()
  81. for y = 0, -8, -1 do
  82. -- Scan from the current block downwards
  83. local block = blocks[1 + (8 + (8 + y)*17 + 8*17^2)]
  84. if block.name ~= "minecraft:air" then
  85. if meta.motionY < -0.3 then
  86. -- If we're moving slowly, then launch ourselves up
  87. modules.launch(0, -90, math.min(4, meta.motionY / -0.5))
  88. end
  89. break
  90. end
  91. end
  92. end
  93. end
  94. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement