Advertisement
ronaldo1e

Location

Nov 20th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local X, Y, Z, O
  2. local North, East, South, West = 0, 1, 2, 3
  3.  
  4. function forward()
  5.   while not turtle.forward() do
  6.     while not turtle.dig() do
  7.       GPSup()
  8.     end
  9.   end
  10. end
  11.  
  12. function locate()
  13.   X, Y2, Z = gps.locate()
  14.   forward()
  15.   X2, Y, Z2 = gps.locate()
  16.   if X2>X then O = East end
  17.   if X2<X then O = West end
  18.   if Z2>Z then O = South end
  19.   if Z2<Z then O = North end
  20.   turtle.back()
  21.   return X, Y, Z, O
  22. end
  23.  
  24. function GPSforward()
  25.   if O == East then X = X+1 end
  26.   if O == West then X = X-1 end
  27.   if O == North then Z = Z-1 end
  28.   if O == South then Z = Z+1 end
  29.   forward()
  30.   end
  31. function GPSturn(Direction)
  32.   while Direction~=O do
  33.     turtle.turnRight()
  34.     O = O + 1
  35.     if O == 4 then O = 0 end
  36.   end
  37. end
  38. function GPSup()
  39.   while not turtle.up() do
  40.     turtle.digUp()
  41.   end
  42.   Y = Y + 1
  43. end
  44. function GPSdown()
  45.   while not turtle.down() do
  46.     turtle.digDown()
  47.   end
  48.   Y = Y - 1
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement