arodalex2000

2

Oct 12th, 2024
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 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. -- Move to the designated chest drop-off point
  48. turtle.back()
  49. turtle.turnLeft()
  50. turtle.forward()
  51. turtle.turnRight()
  52.  
  53. -- Place a chest if there's no chest below already
  54. turtle.select(3)
  55. if not turtle.detectDown() then
  56. turtle.placeDown()
  57. end
  58.  
  59. -- Drop items from slots 4 to 16 into the chest
  60. for i = 4, 16 do
  61. turtle.select(i)
  62. turtle.dropDown()
  63. end
  64.  
  65. -- Move back to the mining position
  66. turtle.select(2) -- Select torches again
  67. turtle.turnRight()
  68. turtle.forward()
  69. turtle.turnLeft()
  70. turtle.forward()
  71. end
  72. end
  73.  
  74. print("Place fuel in slot 1, torches in slot 2, and chests in slot 3!")
  75. print("How wide will the tunnel be?")
  76. local x = tonumber(read())
  77.  
  78. turtle.select(2)
  79. turtle.placeDown()
  80.  
  81. while true do
  82. for i = 1, 9 do
  83. turtle.select(2)
  84. fuelLevel()
  85. moveCoalToSlot1() -- Check and move coal to slot 1 if needed
  86. checkFull()
  87. mine()
  88. turtle.turnLeft()
  89. for j = 1, ((x / 2) - 0.5) do
  90. mine()
  91. end
  92. turtle.turnLeft()
  93. turtle.turnLeft()
  94. for j = 1, (x - 1) do
  95. mine()
  96. end
  97. turtle.turnLeft()
  98. turtle.turnLeft()
  99. for j = 1, ((x / 2) - 0.5) do
  100. turtle.forward()
  101. end
  102. turtle.turnRight()
  103. end
  104. turtle.select(2)
  105. turtle.placeDown()
  106. end
  107.  
Add Comment
Please, Sign In to add comment