Advertisement
Guest User

Works

a guest
Apr 19th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. while true do
  2.   local i = turtle.getFuelLevel()
  3.   if  (i < 200) and (i < 1000) then
  4.     turtle.refuel(1)
  5.   end
  6.   turtle.forward()
  7.   turtle.turnLeft()
  8.   for j = 1, 100 do
  9.     if turtle.detectDown() then
  10.       if turtle.detect() then
  11.         turtle.dig()
  12.         turtle.forward()
  13.         j = j + 1
  14.       else
  15.         turtle.forward()
  16.         j = j + 1
  17.       end
  18.     else
  19.       turtle.down()
  20.     end
  21.   end
  22.   for k = 1, 50 do
  23.     if turtle.detectDown() then
  24.       turtle.dig()
  25.       turtle.digDown()
  26.       turtle.down()
  27.       turtle.dig()
  28.       turtle.forward()
  29.       turtle.turnLeft()
  30.       k = k + 1
  31.     else
  32.       turtle.down()
  33.       turtle.dig()
  34.       turtle.digDown()
  35.       turtle.down()
  36.       turtle.dig()
  37.       turtle.forward()
  38.       turtle.turnLeft()
  39.       k = k + 1
  40.     end
  41.   end
  42.   local x, y, z = gps.locate()
  43.   yDif = y + 1
  44.   zDif = z - 252.62
  45.   xDif = x + 3.94
  46.   if yDif < 0 then
  47.     if turtle.detectUp() then
  48.       turtle.digUp()
  49.       turtle.up()
  50.     else
  51.       turtle.up()
  52.     end
  53.   end
  54.   if yDif > 0 then
  55.     if turtle.detectDown() then
  56.       turtle.digDown()
  57.       turtle.down()
  58.     else
  59.       turtle.down()
  60.     end
  61.   end
  62.  
  63.   local xx, yy, zz = gps.locate();
  64.   xDif2 = xx - x
  65.   zDif2 = zz - z
  66.   if xDif2 > 0 then
  67.     if zDif < 0 then
  68.       turtle.turnLeft()
  69.       while zDif < 0 do
  70.         if turtle.detect() then
  71.           turtle.dig()
  72.           turtle.forward()
  73.           zDif = zDif - zDif2
  74.         else
  75.           turtle.forward()
  76.           zDif = zDif - zDif2
  77.         end
  78.       end
  79.     end
  80.     if zDif > 0 then
  81.       turtle.turnRight()
  82.       while zDif > 0 do
  83.         if turtle.detect() then
  84.           turtle.dig()
  85.           turtle.forward()
  86.           zDif = zDif + zDif2
  87.         else
  88.           turtle.forward()
  89.           zDif = zDif + zDif2
  90.         end
  91.       end
  92.     end
  93.   end
  94.   if xDif2 < 0 then
  95.     if zDif < 0 then
  96.       turtle.turnRight()
  97.       while zDif < 0 do
  98.         if turtle.detect() then
  99.           turtle.dig()
  100.           turtle.forward()
  101.           zDif = zDif - zDif2
  102.         else
  103.           turtle.forward()
  104.           zDif = zDif - zDif2
  105.         end
  106.       end
  107.     end
  108.     if zDif > 0 then
  109.       turtle.turnLeft()
  110.       while zDif > 0 do
  111.         if turtle.detect() then
  112.           turtle.dig()
  113.           turtle.forward()
  114.           zDif = zDif + zDif2
  115.         else
  116.           turtle.forward()
  117.           zDif = zDif + zDif2
  118.         end
  119.       end
  120.     end
  121.   end
  122.   if zDif2 > 0 then
  123.     if zDif < 0 then
  124.       turtle.turnLeft()
  125.       turtle.turnLeft()
  126.       while zDif < 0 do
  127.         if turtle.detect() then
  128.           turtle.dig()
  129.           turtle.forward()
  130.           zDif = zDif + zDif2
  131.         else
  132.           turtle.forward()
  133.           zDif = zDif + zDif2
  134.         end
  135.       end
  136.     end
  137.     if zDif > 0 then
  138.       while zDif > 0 do
  139.         if turtle.detect() then
  140.           turtle.dig()
  141.           turtle.forward()
  142.           zDif = zDif - zDif2
  143.         else
  144.           turtle.forward()
  145.           zDif = zDif - zDif2
  146.         end
  147.       end
  148.     end
  149.   end
  150.   if zDif2 < 0 then
  151.     if zDif < 0 then
  152.       while zDif < 0 do
  153.         if turtle.detect() then
  154.           turtle.dig()
  155.           turtle.forward()
  156.           zDif = zDif - zDif2
  157.         else
  158.           turtle.forward()
  159.           zDif = zDif - zDif2
  160.         end
  161.       end
  162.     end
  163.     if zDif > 0 then
  164.       while zDif > 0 do
  165.         if turtle.detect() then
  166.           turtle.dig()
  167.           turtle.forward()
  168.           zDif = zDif + zDif2
  169.         else
  170.           turtle.forward()
  171.           zDif = zDif + zDif2
  172.         end
  173.       end
  174.     end
  175.   end
  176.  
  177.   turtle.turnLeft()
  178.   local x3, y3, z3 = gps.locate()
  179.   turtle.forward()
  180.   local x4, y4, z4 = gps.locate()
  181.   xDif3 = x4 - x3
  182.  
  183.   if xDif3 < 0 then
  184.     turtle.turnLeft()
  185.     turtle.turnLeft()
  186.     while xDif3 < 0 do
  187.       if turtle.detect() then
  188.         turtle.dig()
  189.         turtle.forward()
  190.         xDif3 = xDif3 - xDif3
  191.       else
  192.         turtle.forward()
  193.         xDif3 = xDif3 - xDif3
  194.       end
  195.     end  
  196.   end
  197.   if xDif3 > 0 then
  198.     turtle.turnLeft()
  199.     turtle.turnLeft()
  200.     while xDif3 > 0 do
  201.       if turtle.detect() then
  202.         turtle.dig()
  203.         turtle.forward()
  204.         xDif3 = xDif3 - xDif3
  205.       else
  206.         turtle.forward()
  207.         xDif3 = xDif3 - xDif3
  208.       end
  209.     end
  210.   end
  211. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement