Cobra_Tomtrein-temp-

Untitled

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