arodalex2000

1

Oct 12th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. function fuelLevel()
  2. if turtle.getFuelLevel() < 1000 then
  3. turtle.select(1)
  4. turtle.refuel(8)
  5. print("Refueled")
  6. else
  7. print("Enough Fuel")
  8. end
  9. end
  10.  
  11. -- Function to move coal to slot 1 if below 40
  12. local function moveCoalToSlot1()
  13. local coalSlot = 1
  14. local currentCoalCount = turtle.getItemCount(coalSlot)
  15. local maxCoalCount = 40 -- Adjust this value as needed
  16.  
  17. if currentCoalCount < maxCoalCount then
  18. for slot = 2, 16 do -- Start from slot 2 to avoid interfering with other items
  19. local item = turtle.getItemDetail(slot)
  20.  
  21. if item and item.name == "minecraft:coal" then
  22. turtle.select(slot)
  23. turtle.transferTo(coalSlot)
  24. return true
  25. end
  26. end
  27. end
  28.  
  29. return false
  30. end
  31.  
  32. function mine()
  33. while turtle.detect() do
  34. turtle.dig()
  35. sleep(0.5)
  36. end
  37. turtle.forward()
  38. while turtle.detectUp() do
  39. turtle.digUp()
  40. sleep(0.5)
  41. end
  42. turtle.digDown()
  43. end
  44.  
  45. function checkFull()
  46. if turtle.getItemCount(16) > 0 then
  47. turtle.back()
  48. turtle.turnLeft()
  49. turtle.forward()
  50. turtle.turnRight()
  51. turtle.select(3)
  52. turtle.placeDown()
  53. for i = 4, 16 do
  54. turtle.select(i)
  55. turtle.dropDown()
  56. end
  57. turtle.select(3)
  58. turtle.digDown()
  59. turtle.select(2)
  60. turtle.turnRight()
  61. turtle.forward()
  62. turtle.turnLeft()
  63. turtle.forward()
  64. end
  65. end
  66.  
  67. print("Place fuel in slot 1, torches in slot 2, and chests in slot 3!")
  68. print("How wide will the tunnel be?")
  69. local x = tonumber(read())
  70.  
  71. turtle.select(2)
  72. turtle.placeDown()
  73.  
  74. while true do
  75. for i = 1, 9 do
  76. turtle.select(2)
  77. fuelLevel()
  78. moveCoalToSlot1() -- Check and move coal to slot 1 if needed
  79. checkFull()
  80. mine()
  81. turtle.turnLeft()
  82. for j = 1, ((x / 2) - 0.5) do
  83. mine()
  84. end
  85. turtle.turnLeft()
  86. turtle.turnLeft()
  87. for j = 1, (x - 1) do
  88. mine()
  89. end
  90. turtle.turnLeft()
  91. turtle.turnLeft()
  92. for j = 1, ((x / 2) - 0.5) do
  93. turtle.forward()
  94. end
  95. turtle.turnRight()
  96. end
  97. turtle.select(2)
  98. turtle.placeDown()
  99. end
Advertisement
Add Comment
Please, Sign In to add comment