Advertisement
Guest User

navi

a guest
Aug 1st, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 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 getDirecX()
  7.       if x > cx then
  8.         dirX = 1
  9.       else
  10.         dirX = 3
  11.       end
  12.   end
  13.   function getDirecZ()    
  14.     if cz > z then
  15.       dirZ = 0
  16.     else
  17.       dirZ = 2
  18.   end
  19.   end
  20.  
  21.   function calx()
  22.     for i = 1, dirX do
  23.       turtle.turnRight()
  24.     end
  25.   end
  26.   function calz()
  27.     for p = 1,dirZ do
  28.       turtle.turnRight()
  29.     end
  30.   end
  31.   function uncalx()
  32.     for k = 1, dirX do
  33.       turtle.turnLeft()
  34.     end
  35.   end        
  36.   function uncalz()
  37.     for o = 1, dirZ do
  38.       turtle.turnLeft()
  39.     end
  40.   end
  41.   function goZ()
  42.     getDirecZ()
  43.     calz()
  44.     distzz = cz - z
  45.     distz = math.abs(distzz)
  46.     for p = 1, distz do
  47.       turtle.forward()
  48.      
  49.     end
  50.     uncalz()
  51.   end
  52.   function goX()
  53.     getDirecX()
  54.     calx()
  55.     distxx = cx - x
  56.     distx = math.abs(distxx)
  57.     for q = 1, distx do
  58.      turtle.dig()
  59.      turtle.forward()
  60.     end
  61.     uncalx()
  62.   end  
  63.   goZ()
  64.   goX()    
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement