Leivar

digQuarry

Nov 16th, 2020 (edited)
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. posH = 0
  2. posW = 0
  3. input = 0
  4. ready = 0
  5. line = 0
  6. function checkFuel()
  7.     local fuel = turtle.getFuelLevel()
  8.     local fuelRequired = input*18
  9.     if fuel <= fuelRequired then
  10.         print('Not enough fuel for this mission')
  11.     end
  12.  
  13.     if fuel > fuelRequired then
  14.         ready = 1
  15.     end
  16. end
  17.  
  18. function checkInventory()
  19.     turtle.select(15)
  20.     if turtle.getItemCount() > 0 then
  21.         for i = 1, posW do
  22.             turtle.back()
  23.         end
  24.         for j = 1, posH do
  25.             turtle.up()
  26.         end
  27.         turtle.turnLeft()
  28.         turtle.turnLeft()
  29.         for k = 1, 16 do
  30.             turtle.select(k)
  31.             turtle.drop()
  32.         end
  33.         turtle.select(1)
  34.         turtle.turnLeft()
  35.         turtle.turnLeft()
  36.         for l = 1, posW do
  37.             turtle.forward()
  38.         end
  39.         for m = 1, posH do
  40.             turtle.down()
  41.         end
  42.     end
  43.     turtle.select(1)
  44. end
  45.  
  46. function mineLine()
  47.     turtle.digDown()
  48.     turtle.down()
  49.     posH = posH + 1
  50.     turtle.turnLeft()
  51.     turtle.dig()
  52.     turtle.turnRight()
  53.     turtle.turnRight()
  54.     turtle.dig()
  55.     turtle.turnLeft()
  56. end
  57.  
  58. print('What height am I standing at?')
  59. local number = tonumber(io.read())
  60. if tonumber(number) ~= nil then
  61.    input = number - 1
  62. end
  63.  
  64. checkFuel()
  65.     if ready == 1 then
  66.     repeat
  67.         for n = 1, input do
  68.             mineLine()
  69.             checkInventory()
  70.         end
  71.         for o = 1, posW do
  72.             turtle.back()
  73.         end
  74.         for p = 1, posH do
  75.             turtle.up()
  76.         end
  77.         turtle.turnLeft()
  78.         turtle.turnLeft()
  79.         for q = 1, 16 do
  80.             turtle.select(q)
  81.             turtle.drop()
  82.         end
  83.         turtle.turnLeft()
  84.         turtle.turnLeft()
  85.         posH = 0
  86.         if line < 2 then
  87.             for x = 0, line do
  88.                 turtle.forward()
  89.             end
  90.         end
  91.         posW = posW + 1
  92.         line = line + 1
  93.     until line == 3
  94. end
  95.  
Advertisement
Add Comment
Please, Sign In to add comment