Samotage820

cc turtle excavator

Jul 27th, 2021 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. function digPlane(x,y)
  2.     for i=0,y-1 do
  3.         for i=0,x-1 do
  4.             invCheck()
  5.             turtle.dig()
  6.             turtle.forward()
  7.         end
  8.         if i==y then
  9.             if y%2==0 then
  10.                 turtle.turnLeft()
  11.             else
  12.                 for j=0,x do
  13.                     turtle.back()
  14.                 end
  15.                 turtle.turnRight()
  16.             end
  17.             for j=0,y do
  18.                 turtle.forward()
  19.             end
  20.             turtle.turnLeft()
  21.         elseif i%2==0 then
  22.             turtle.turnLeft()
  23.             turtle.dig()
  24.             turtle.forward()
  25.             turtle.turnLeft()
  26.         else
  27.             turtle.turnRight()
  28.             turtle.dig()
  29.             turtle.forward()
  30.             turtle.turnRight()
  31.         end
  32.     end
  33. end
  34.  
  35. function digVolume(x,y,z)
  36.     for i=0,z-1 do
  37.         if fuelCheck(x+y+z) and turtle.digDown() then
  38.             turtle.down()
  39.             digPlane(x,y)
  40.         else
  41.             break
  42.         end
  43.     end
  44. end
  45.  
  46. function fuelCheck(threshold)
  47.     fuel = turtle.getFuelLevel()
  48.     print("Current fuel: ",fuel)
  49.     if fuel <= threshold then
  50.         print("Fuel low!")
  51.         return turtle.refuel()
  52.     end
  53.     return true
  54. end
  55.  
  56. function invCheck()
  57.     if turtle.getItemDetail(14) ~= nil then
  58.         turtle.up()
  59.         turtle.select(16)
  60.         turtle.placeUp()
  61.         for i=2,15 do
  62.             turtle.select(i)
  63.             turtle.dropUp()
  64.         end
  65.         turtle.select(1)
  66.         turtle.down()
  67.     end
  68. end
Add Comment
Please, Sign In to add comment