Advertisement
Guest User

navi

a guest
Aug 1st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. function goto(xx,zz)
  2.   x = tonumber(xx)
  3.   z = tonumber(zz)
  4.  rednet.open("left")
  5.    cx, cy, cz = gps.locate()
  6.   function getDirec()
  7.     if z == cz then
  8.       if x > cx then
  9.         dir = 1
  10.       else
  11.         dir = 3
  12.       end
  13.     elseif cz > z then
  14.       dir = 0
  15.     else
  16.       dir = 2
  17.     end
  18.   end
  19.   function cal()
  20.     for i = 1, dir do
  21.       turtle.turnRight()
  22.     end
  23.   end
  24.   function uncal()
  25.     for o = 1, dir do
  26.       turtle.turnLeft()
  27.     end
  28.   end
  29.   function goZ()
  30.     getDirec()
  31.     cal()
  32.     distzz = cz - z
  33.     distz = math.abs(distzz)
  34.     for p = 1, distz do
  35.       turtle.forward()
  36.      
  37.     end
  38.     uncal()
  39.   end
  40.   function goX()
  41.     getDirec()
  42.     cal()
  43.     distxx = cx - x
  44.     distx = math.abs(distxx)
  45.     for q = 1, distx do
  46.      turtle.dig()
  47.      turtle.forward()
  48.     end
  49.     uncal()
  50.   end  
  51.   goZ()
  52.   goX()    
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement