Advertisement
KTRD

lonely digging

Feb 17th, 2025 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. function waitForEmpty()
  2.     local f = false
  3.     if turtle.getItemCount(16) > 0 then
  4.         f = true
  5.         print("Inventory full, remove items manually")
  6.         os.sleep(10)
  7.     end
  8.     while turtle.getItemCount(16) > 0 do
  9.         os.sleep(10)
  10.     end
  11.     if f then print("Space freed, resuming") end
  12. end
  13. function waitForTorches()
  14.     local f = false
  15.     if turtle.getItemCount(1) < 2 then
  16.         f = true
  17.         print("No torches, put them in the slot number 1")
  18.         os.sleep(10)
  19.     end
  20.     while turtle.getItemCount(1) < 2 do
  21.         os.sleep(10)
  22.     end
  23.     if f then print("Torches found, resuming") end
  24. end
  25. function waitForFuel()
  26.     turtle.select(2)
  27.     local f = false
  28.     if not turtle.refuel(0) then
  29.         f = true
  30.         print("No fuel, put fuel in the slot number 2")
  31.         os.sleep(10)
  32.     end
  33.     if f then print("Fuel found, resuming") end
  34.     while not turtle.refuel(0) do
  35.         os.sleep(10)
  36.     end
  37.     while turtle.getFuelLevel() < 80 do
  38.         turtle.refuel(1)
  39.     end
  40.     turtle.select(1)
  41. end
  42. function waitForChests()
  43.     local f = false
  44.     if turtle.getItemCount(3) == 0 then
  45.         f = true
  46.         print("No chests, put chests in the slot number 3")
  47.         os.sleep(10)
  48.     end
  49.     while turtle.getItemCount(3) == 0 do
  50.         os.sleep(10)
  51.     end
  52.     if f then print("Chests found, resuming") end
  53. end
  54. function forward()
  55.     while not turtle.forward() do
  56.         turtle.dig()
  57.         waitForEmpty()
  58.     end
  59. end
  60. function dig()
  61.     turtle.dig()
  62.     waitForEmpty()
  63.     turtle.digUp()
  64.     waitForEmpty()
  65.     turtle.digDown()
  66.     waitForEmpty()
  67.     forward()
  68. end
  69. n = 0
  70. while true do
  71.     n = math.fmod(n + 1, 2)
  72.     waitForFuel()
  73.     waitForTorches()
  74.     waitForChests()
  75.     dig()
  76.     turtle.turnLeft()
  77.     for i = 1,12 do
  78.         dig()
  79.     end
  80.     turtle.turnLeft()
  81.     turtle.turnLeft()
  82.     for i = 1,7 do forward() end
  83.     turtle.placeDown()
  84.     waitForTorches()
  85.     for i = 1,5 do forward() end
  86.     for i = 1,12 do
  87.         dig()
  88.     end
  89.     turtle.turnLeft()
  90.     turtle.turnLeft()
  91.     for i = 1,7 do forward() end
  92.     turtle.placeDown()
  93.     waitForTorches()
  94.     for i = 1,5 do forward() end
  95.     turtle.turnRight()
  96.     if n == 0 then
  97.         turtle.select(3)
  98.         turtle.placeDown()
  99.         for i = 4,16 do
  100.             turtle.select(i)
  101.             turtle.dropDown()
  102.         end
  103.         turtle.select(1)
  104.         waitForChests()
  105.     end
  106.     forward()
  107.     dig()
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement