Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ******************************* --
- -- Autopilot Programme by Jharrakn --
- -- ******************************* --
- function stop(message)
- print("autopilot encountered an error and stopped")
- print("message recieved was:")
- print(message)
- print("")
- print("press r to restart")
- while true do
- local event, character = os.pullEvent()
- if event == "char" and character == "r" then break end
- end
- os.reboot()
- end
- local args = { ... }
- if args[1] == nil or args[2] == nil then
- stop("program should be called with [x coord] [y coord]")
- end
- rednet.open("top")
- local x, y, z = gps.locate(5, false)
- if x == nil then stop("gps error") end
- while x ~= tonumber(args[1]) do
- if x < tonumber(args[1]) then
- redstone.setBundledOutput("right", colors.white)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- redstone.setBundledOutput("right", colors.white)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- elseif x > tonumber(args[1]) then
- redstone.setBundledOutput("right", colors.magenta)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- redstone.setBundledOutput("right", colors.magenta)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- end
- x = nil
- x, y, z = gps.locate(5, false)
- if x == nil then stop("gps error") end
- end
- while y ~= tonumber(args[2]) do
- if y < tonumber(args[2]) then
- redstone.setBundledOutput("right", colors.lightBlue)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- redstone.setBundledOutput("right", colors.lightBlue)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- elseif y > tonumber(args[2]) then
- redstone.setBundledOutput("right", colors.orange)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- redstone.setBundledOutput("right", colors.orange)
- sleep(0.5)
- redstone.setBundledOutput("right", 0)
- sleep(0.5)
- end
- x = nil
- x, y, z = gps.locate(5, false)
- if x == nil then stop("gps error") end
- end
- print("arrived at destination")
Advertisement
Add Comment
Please, Sign In to add comment