Advertisement
Muire

turtle

Mar 4th, 2025 (edited)
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. -- Ancient Debris Strip Mining Turtle Script
  2.  
  3. local targetY = 14 -- Starting Y level (reference point)
  4. local miningLength = 50 -- Blocks to mine forward
  5. local chestSlot = 1 -- Slot for chest interaction
  6. local netherrackSlot = 2 -- Slot to keep netherrack
  7.  
  8. -- Function to check and maintain 64 netherrack
  9. local function maintainNetherrack()
  10. turtle.select(netherrackSlot)
  11. local count = turtle.getItemCount(netherrackSlot)
  12. if count < 64 then
  13. print("Need more netherrack: "..count.."/64")
  14. return false
  15. end
  16. return true
  17. end
  18.  
  19. -- Function to handle lava blocking
  20. local function checkAndBlockLava()
  21. if turtle.detect() then
  22. local success, block = turtle.inspect()
  23. if block and block.name == "minecraft:lava" then
  24. turtle.select(netherrackSlot)
  25. turtle.place()
  26. return true
  27. end
  28. end
  29. return false
  30. end
  31.  
  32. -- Function to refuel from chest and deposit
  33. local function refuelFromChest()
  34. turtle.turnLeft()
  35. turtle.turnLeft()
  36. turtle.select(chestSlot)
  37.  
  38. -- Suck coal and refuel
  39. while turtle.getFuelLevel() < 1000 do
  40. turtle.suck()
  41. for i = 1, 16 do
  42. turtle.select(i)
  43. if turtle.refuel(1) then
  44. break
  45. end
  46. end
  47. end
  48.  
  49. -- Deposit ancient debris
  50. for i = 1, 16 do
  51. turtle.select(i)
  52. local item = turtle.getItemDetail()
  53. if item and item.name == "minecraft:ancient_debris" then
  54. turtle.drop()
  55. end
  56. end
  57.  
  58. turtle.select(chestSlot)
  59. turtle.turnRight()
  60. turtle.turnRight()
  61. end
  62.  
  63. -- Function to move to specific Y level
  64. local function moveToY(target)
  65. -- Since turtles don't track Y, we'll assume starting at 14
  66. -- and adjust relative to that
  67. local currentY = 14 -- Assuming start at Y=14
  68. while currentY ~= target do
  69. if currentY > target then
  70. turtle.digDown()
  71. turtle.down()
  72. currentY = currentY - 1
  73. elseif currentY < target then
  74. turtle.digUp()
  75. turtle.up()
  76. currentY = currentY + 1
  77. end
  78. end
  79. end
  80.  
  81. -- Main mining function for one row
  82. local function mineRow()
  83. for y = 12, 16 do
  84. moveToY(y)
  85. for i = 1, miningLength do
  86. checkAndBlockLava()
  87. turtle.dig()
  88. turtle.forward()
  89. checkAndBlockLava()
  90. if not maintainNetherrack() then
  91. -- Return to Y=14 before exiting
  92. moveToY(14)
  93. return false
  94. end
  95. end
  96. -- Return to start of row after each Y level
  97. turtle.turnLeft()
  98. turtle.turnLeft()
  99. for i = 1, miningLength do
  100. turtle.forward()
  101. end
  102. turtle.turnRight()
  103. turtle.turnRight()
  104. end
  105. moveToY(14) -- Return to starting Y level
  106. return true
  107. end
  108.  
  109. -- Main program
  110. print("Starting Ancient Debris Strip Mining...")
  111. print("Place chest with coal BEHIND turtle at Y=14")
  112. print("Ensure slot 2 has 64+ netherrack")
  113. print("Turtle must start at Y=14 facing mining direction")
  114.  
  115. -- Initial setup
  116. turtle.select(netherrackSlot)
  117. if not maintainNetherrack() then
  118. print("Please put 64+ netherrack in slot 2")
  119. return
  120. end
  121.  
  122. local rowCount = 0
  123.  
  124. while true do
  125. if mineRow() then
  126. -- Return to start position
  127. turtle.turnLeft()
  128. turtle.turnLeft()
  129. for i = 1, miningLength do
  130. turtle.forward()
  131. end
  132.  
  133. refuelFromChest()
  134.  
  135. -- Move to next adjacent row
  136. turtle.turnRight()
  137. turtle.forward()
  138. turtle.turnRight()
  139.  
  140. rowCount = rowCount + 1
  141. if rowCount >= 10 then -- Adjust this for number of rows desired
  142. print("Completed "..rowCount.." rows")
  143. break
  144. end
  145. else
  146. print("Returning due to low netherrack")
  147. turtle.turnLeft()
  148. turtle.turnLeft()
  149. for i = 1, miningLength do
  150. turtle.forward()
  151. end
  152. refuelFromChest()
  153. break
  154. end
  155. end
  156.  
  157. print("Mining complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement