Aarondmorgan

Turtle GPS Framework

Jun 29th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. rednet.open("right")
  2. shell.run("clear")
  3. print("Please ensure that I am facing North.")
  4. print("If I am not facing North, I will not make it to my destination.")
  5. sleep(5)
  6. print("Beginning journey in...")
  7. print("5")
  8. sleep(1)
  9. print("4")
  10. sleep(1)
  11. print("3")
  12. sleep(1)
  13. print("2")
  14. sleep(1)
  15. print("1")
  16. sleep(1)
  17. print("Beginning journey now.")
  18.  
  19. local x, y, z = gps.locate()
  20.  
  21. function ymoveup()
  22. updist = 10
  23.     repeat
  24.         turtle.up()
  25.         updist = updist - 1
  26.     until updist == 0
  27.     updist = 10
  28. end
  29.  
  30. function zmove()
  31.     if z > 1096 then
  32.         zdist = z - 1096
  33.         repeat
  34.             turtle.forward()
  35.             zdist = zdist - 1
  36.         until zdist == 0
  37.     end
  38.     if z < 1096 then
  39.         zdist = z - 1096
  40.         zdist = zdist * -1
  41.         turtle.turnRight()
  42.         turtle.turnRight()
  43.         repeat
  44.             turtle.forward()
  45.             zdist = zdist - 1
  46.         until zdist == 0
  47.         turtle.turnRight()
  48.         turtle.turnRight()
  49.     end
  50.     turtle.turnLeft()
  51. end
  52.  
  53. function xmove()
  54.     if x > 251 then
  55.         xdist = x - 251
  56.         repeat
  57.             turtle.forward()
  58.             xdist = xdist - 1
  59.         until xdist == 0
  60.     end
  61.     if x < 251 then
  62.         xdist = x - 251
  63.         xdist = xdist * -1
  64.         turtle.turnRight()
  65.         turtle.turnRight()
  66.         repeat
  67.             turtle.forward()
  68.             xdist = xdist - 1
  69.         until xdist == 0
  70.         turtle.turnRight()
  71.         turtle.turnRight()
  72.     end
  73. end
  74.  
  75. function ymovedown()
  76.     y = y + updist
  77.     ydist = y - 68
  78.     repeat
  79.         turtle.down()
  80.         ydist = ydist - 1
  81.     until ydist == 0
  82.     turtle.turnRight()
  83. end
  84.  
  85. function finished()
  86.     shell.run("clear")
  87.     print("Destination reached.")
  88.     print("I am a good turtle.")
  89.     print("Please pet me.")
  90. end
  91.  
  92. ymoveup()
  93. zmove()
  94. xmove()
  95. ymovedown()
  96. finished()
Advertisement
Add Comment
Please, Sign In to add comment