Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local core = peripheral.find("warpdriveShipCore")
- -- Get the current position
- local currentX, currentY, currentZ = core.getLocalPosition()
- core.enable(true)
- core.command("IDLE", false)
- local targetX =
- local targetY =
- local targetZ =
- -- Make sure the temp file exists --
- if fs.exists("temp") then
- else
- fs.open("temp", "w")
- local h = fs.open("temp", "w")
- h.close()
- end
- ------------------------------------
- local h = fs.open("temp", "r")
- if h.readAll() == "t" then
- h.close()
- -- Calculate the required movement
- local LatMove = targetX - currentX
- local VerMove = targetY - currentY
- local ForMove = targetZ - currentZ
- -- Check if both targetX and currentX are negative and their sum is positive
- if targetX < 0 and currentX < 0 and (targetX - currentX) > 0 then
- -- Flip the sign of the sum to make it negative
- local flip = (targetX - currentX) * -1
- LatMove = flip
- end
- -- Check if both targetZ and currentZ are negative and their sum is positive
- if targetZ < 0 and currentZ < 0 and (targetZ - currentZ) > 0 then
- -- Flip the sign of the sum to make it negative
- local flip = (targetZ - currentZ) * -1
- ForMove = flip
- end
- print("Calculated Movement")
- print(ForMove, VerMove, LatMove)
- core.movement(ForMove, VerMove, LatMove)
- print("")
- print("Continually jumping...")
- core.enable(true)
- core.command("IDLE", false)
- sleep(1)
- core.command("MANUAL", true)
- print("Press `space` to stop jumping")
- local event, key = os.pullEvent("key")
- if key == keys.space then
- local h = fs.open("temp", "w")
- h.writeLine("f")
- h.close()
- print("Movement stopped for next jump")
- end
- else
- h.close()
- -- Input the target coordinates
- -- print("Please input target X coordinate: ")
- -- targetX = tonumber(read())
- -- print("Please input target Y coordinate: ")
- -- targetY = tonumber(read())
- -- print("Please input target Z coordinate: ")
- -- targetZ = tonumber(read())
- -- Calculate the required movement
- local ForMove = targetX - currentX
- local VerMove = targetY - currentY
- local LatMove = targetZ - currentZ
- -- Check if both targetX and currentX are negative and their sum is positive
- if targetX < 0 and currentX < 0 and (targetX - currentX) > 0 then
- -- Flip the sign of the sum to make it negative
- local flip = (targetX + currentX) * -1
- LatMove = flip
- end
- -- Check if both targetZ and currentZ are negative and their sum is positive
- if targetZ < 0 and currentZ < 0 and (targetZ - currentZ) > 0 then
- -- Flip the sign of the sum to make it negative
- local flip = (targetZ + currentZ) * -1
- ForMove = flip
- end
- print("Calculated Movement")
- print(ForMove, VerMove, LatMove)
- core.movement(ForMove, VerMove, LatMove)
- print("")
- print("Starting continual jumping")
- print("Press `Space` after a jump to stop jumping")
- core.command("MANUAL", true)
- print("Starting Auto-pilot")
- local h = fs.open("temp", "w")
- h.write("t")
- h.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement