Firnagzen

Untitled

May 28th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. --- Wrap interface
  2. local modules = peripheral.find("neuralInterface")
  3. if not modules then
  4. error("Missing neural interface", 0)
  5. end
  6.  
  7. --- Get modules
  8. if not modules.hasModule("plethora:sensor") then error("Missing sensor", 0) end
  9. if not modules.hasModule("plethora:scanner") then error("Missing scanner", 0) end
  10. if not modules.hasModule("plethora:introspection") then error("Missing introspection module", 0) end
  11. if not modules.hasModule("plethora:kinetic", 0) then error("Missing kinetic agument", 0) end
  12.  
  13. -- Constants
  14. local doubleTapTime = 0.4
  15. local pitchAdjust = 60
  16. local airName = "minecraft:air"
  17. local requiredAir = 3
  18.  
  19. -- Check for air below
  20. function checkAirborne(nAir)
  21. for n = 2, 2 + requiredAir do
  22. if modules.getBlockMeta(0, -n, 0).name ~= airName then
  23. return false
  24. end
  25. end
  26. return true
  27. end
  28.  
  29.  
  30. -- Run YEET
  31. local meta = {}
  32. local lastSpacePress = 0
  33.  
  34. -- Announce starting
  35. print("YEET")
  36.  
  37. -- Main loops
  38. parallel.waitForAny(
  39. function()
  40. while true do
  41. local event, key = os.pullEvent()
  42.  
  43. if event == "key_up" and key == keys.space then
  44. -- Get current time
  45. local currTime = os.clock()
  46.  
  47. if (currTime - lastSpacePress) < doubleTapTime then
  48. -- Yeet if doubletap
  49. modules.launch(meta.yaw, meta.pitch, 4)
  50.  
  51. elseif checkAirborne(requiredAir) then
  52. -- Yeet slightly upwards if not pointing straight up or down
  53. local pitch = meta.pitch - math.cos(meta.pitch / 180 * math.pi) ^ 2 * pitchAdjust
  54.  
  55. -- yeet if airborne
  56. modules.launch(meta.yaw, pitch, 4)
  57.  
  58. end
  59.  
  60. lastSpacePress = currTime
  61. end
  62. end
  63. end,
  64.  
  65. function()
  66. -- Owner metadata update in separate loop for timing purposes
  67. while true do
  68. meta = modules.getMetaOwner()
  69. end
  70. end
  71. )
Advertisement
Add Comment
Please, Sign In to add comment