Jharakn

Untitled

Jan 11th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1.  
  2. -- ******************************* --
  3. -- Autopilot Programme by Jharrakn --
  4. -- ******************************* --
  5.  
  6. function stop(message)
  7. print("autopilot encountered an error and stopped")
  8. print("message recieved was:")
  9. print(message)
  10. print("")
  11. print("press r to restart")
  12. while true do
  13. local event, character = os.pullEvent()
  14. if event == "char" and character == "r" then break end
  15. end
  16. os.reboot()
  17. end
  18.  
  19. local args = { ... }
  20.  
  21. if args[1] == nil or args[2] == nil then
  22. stop("program should be called with [x coord] [y coord]")
  23. end
  24.  
  25.  
  26. rednet.open("top")
  27. local x, y, z = gps.locate(5, false)
  28. if x == nil then stop("gps error") end
  29.  
  30. while x ~= tonumber(args[1]) do
  31. if x < tonumber(args[1]) then
  32. redstone.setBundledOutput("right", colors.white)
  33. sleep(0.5)
  34. redstone.setBundledOutput("right", 0)
  35. sleep(0.5)
  36. redstone.setBundledOutput("right", colors.white)
  37. sleep(0.5)
  38. redstone.setBundledOutput("right", 0)
  39. sleep(0.5)
  40. elseif x > tonumber(args[1]) then
  41. redstone.setBundledOutput("right", colors.magenta)
  42. sleep(0.5)
  43. redstone.setBundledOutput("right", 0)
  44. sleep(0.5)
  45. redstone.setBundledOutput("right", colors.magenta)
  46. sleep(0.5)
  47. redstone.setBundledOutput("right", 0)
  48. sleep(0.5)
  49. end
  50.  
  51. x = nil
  52. x, y, z = gps.locate(5, false)
  53. if x == nil then stop("gps error") end
  54. end
  55.  
  56. while y ~= tonumber(args[2]) do
  57. if y < tonumber(args[2]) then
  58. redstone.setBundledOutput("right", colors.lightBlue)
  59. sleep(0.5)
  60. redstone.setBundledOutput("right", 0)
  61. sleep(0.5)
  62. redstone.setBundledOutput("right", colors.lightBlue)
  63. sleep(0.5)
  64. redstone.setBundledOutput("right", 0)
  65. sleep(0.5)
  66. elseif y > tonumber(args[2]) then
  67. redstone.setBundledOutput("right", colors.orange)
  68. sleep(0.5)
  69. redstone.setBundledOutput("right", 0)
  70. sleep(0.5)
  71. redstone.setBundledOutput("right", colors.orange)
  72. sleep(0.5)
  73. redstone.setBundledOutput("right", 0)
  74. sleep(0.5)
  75. end
  76.  
  77. x = nil
  78. x, y, z = gps.locate(5, false)
  79. if x == nil then stop("gps error") end
  80. end
  81.  
  82. print("arrived at destination")
Advertisement
Add Comment
Please, Sign In to add comment