Advertisement
Ask0nn

Digger.NET

Nov 22nd, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.91 KB | None | 0 0
  1. xCord, yCord, zCord, blockcount, xDCord, yDCord, zDCord = 0,0,0,0,1,1,1;
  2.  
  3. local function setxyz()
  4.   print("Warning if you enter values greater than 64 errors are possible");
  5.   io.write("Input X (Forward): ");
  6.   xCord = io.read();
  7.   io.write("Input Z (Right): ");
  8.   zCord = io.read();
  9.   io.write("Input Y (UP): ");
  10.   yCord = io.read();
  11.   print("The expected number of blocks: "..(xCord * yCord * zCord));
  12.   blockcount = xCord * yCord * zCord;
  13. end
  14.  
  15. local function checkFuel()
  16.   if (turtle.getFuelLevel() <= 10) then
  17.     repeat
  18.       io.write("Plase any fuel in grid and press any button");
  19.       io.read();
  20.       turtle.refuel("all");
  21.     until turtle.getFuelLevel() > 10
  22.   end
  23.   print("Fuel level: "..turtle.getFuelLevel());
  24. end
  25.  
  26. local function digingUP()
  27.   for y = 1, yCord - 1 do
  28.     yDCord = y;
  29.     turtle.digUp();
  30.     blockcount = blockcount -1;
  31.     while turtle.up() == false do
  32.       turtle.digUp();
  33.       turtle.attackUp();
  34.       checkFuel();
  35.     end
  36.     checkFuel();
  37.     print(blockcount);
  38.     print(xDCord.."--"..yDCord.."--"..zDCord);
  39.   end
  40. end
  41.  
  42. local function digingDown()
  43.   for y = 1, yCord - 1 do
  44.     yDCord = yDCord - 1;
  45.     turtle.digDown();
  46.     blockcount = blockcount -1;
  47.     while turtle.down() == false do
  48.       turtle.digDown();
  49.       turtle.attackDown();
  50.       checkFuel();
  51.     end
  52.     checkFuel();
  53.     print(blockcount);
  54.     print(xDCord.."--"..yDCord.."--"..zDCord);
  55.   end
  56.   yDCord = 1;
  57.   print(xDCord.."--"..yDCord.."--"..zDCord);
  58. end
  59.  
  60. local function digingXUp()
  61.   for x = 1, xCord do
  62.     xDCord = x;
  63.     if (tonumber(xDCord) == 0) then xDCord = 1; end
  64.     if (yDCord == 1) then
  65.       digingUP();
  66.     else
  67.       digingDown();
  68.     end
  69.     if (x <= xCord - 1) then
  70.       turtle.dig();
  71.       blockcount = blockcount -1;
  72.       while turtle.forward() == false do
  73.         turtle.dig();
  74.         turtle.attack();
  75.         checkFuel();
  76.       end
  77.       print(xDCord.."--"..yDCord.."--"..zDCord);
  78.       checkFuel();
  79.     end
  80.   end
  81. end
  82.  
  83. local function digingXDown()
  84.   for x = 1, xCord do
  85.     xDCord = xDCord - 1;
  86.     if (tonumber(xDCord) == 0) then xDCord = 1; end
  87.     if (yDCord == 1) then
  88.       digingUP();
  89.     else
  90.       digingDown();
  91.     end
  92.     if (x <= xCord - 1) then
  93.       turtle.dig();
  94.       blockcount = blockcount -1;
  95.       while turtle.forward() == false do
  96.         turtle.dig();
  97.         turtle.attack();
  98.         checkFuel();
  99.       end
  100.       if (tonumber(xDCord) == 0) then xDCord = 1; end
  101.       print(xDCord.."--"..yDCord.."--"..zDCord);
  102.       checkFuel();
  103.     end
  104.   end
  105. end
  106.  
  107. local function diging()
  108.   print("Start Diging");
  109.   if (blockcount == 0 or blockcount == 1) then
  110.     return false;
  111.   else
  112.     checkFuel();
  113.     for z = 1, zCord do
  114.       zDCord = z;
  115.       if (z % 2 == 0) then
  116.         digingXDown();
  117.         if (z < tonumber(zCord)) then
  118.           turtle.turnLeft();
  119.           turtle.dig();
  120.           blockcount = blockcount -1;
  121.           while turtle.forward() == false do
  122.             turtle.dig();
  123.             turtle.attack();
  124.             checkFuel();
  125.           end
  126.           turtle.turnLeft()
  127.           checkFuel();
  128.           print(xDCord.."--"..yDCord.."--"..zDCord);
  129.         end
  130.       else
  131.         digingXUp();
  132.         if (z < tonumber(zCord)) then
  133.           turtle.turnRight();
  134.           turtle.dig();
  135.           blockcount = blockcount -1;
  136.           while turtle.forward() == false do
  137.             turtle.dig();
  138.             turtle.attack();
  139.             checkFuel();
  140.           end
  141.           turtle.turnRight();
  142.           checkFuel();
  143.           print(xDCord.."--"..yDCord.."--"..zDCord);
  144.         end
  145.       end
  146.     end
  147.   end
  148.     return true;
  149. end
  150.  
  151. local function backToStartPosition()
  152.   for i = 1, 16 do
  153.    
  154.   end
  155. end
  156.  
  157. setxyz();
  158. if (xCord == nil or yCord == nil or zCord == nil) then
  159.   print("Error input data");
  160.   return;
  161. else
  162.   diging();
  163.   print("Fuel level: "..turtle.getFuelLevel());
  164.   print("Done");
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement