Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Wrap interface
- local modules = peripheral.find("neuralInterface")
- if not modules then
- error("Missing neural interface", 0)
- end
- --- Get modules
- if not modules.hasModule("plethora:sensor") then error("Missing sensor", 0) end
- if not modules.hasModule("plethora:scanner") then error("Missing scanner", 0) end
- if not modules.hasModule("plethora:introspection") then error("Missing introspection module", 0) end
- if not modules.hasModule("plethora:kinetic", 0) then error("Missing kinetic agument", 0) end
- -- Constants
- local doubleTapTime = 0.4
- local pitchAdjust = 60
- local airName = "minecraft:air"
- local requiredAir = 3
- -- Check for air below
- function checkAirborne(nAir)
- for n = 2, 2 + requiredAir do
- if modules.getBlockMeta(0, -n, 0).name ~= airName then
- return false
- end
- end
- return true
- end
- -- Run YEET
- local meta = {}
- local lastSpacePress = 0
- -- Announce starting
- print("YEET")
- -- Main loops
- parallel.waitForAny(
- function()
- while true do
- local event, key = os.pullEvent()
- if event == "key_up" and key == keys.space then
- -- Get current time
- local currTime = os.clock()
- if (currTime - lastSpacePress) < doubleTapTime then
- -- Yeet if doubletap
- modules.launch(meta.yaw, meta.pitch, 4)
- elseif checkAirborne(requiredAir) then
- -- Yeet slightly upwards if not pointing straight up or down
- local pitch = meta.pitch - math.cos(meta.pitch / 180 * math.pi) ^ 2 * pitchAdjust
- -- yeet if airborne
- modules.launch(meta.yaw, pitch, 4)
- end
- lastSpacePress = currTime
- end
- end
- end,
- function()
- -- Owner metadata update in separate loop for timing purposes
- while true do
- meta = modules.getMetaOwner()
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment