Advertisement
Guest User

Works

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