Advertisement
Maxello_

tutel drop test

Aug 22nd, 2024 (edited)
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. -- Define the trash items
  2. local trashItems = {
  3. "minecraft:dirt",
  4. "minecraft:cobblestone",
  5. "minecraft:diorite"
  6. }
  7.  
  8. -- Function to check if an item is trash
  9. local function isTrash(item)
  10. for _, trash in ipairs(trashItems) do
  11. if item == trash then
  12. return true
  13. end
  14. end
  15. return false
  16. end
  17.  
  18. -- Function to automatically drop trash items from the inventory
  19. local function dropTrash()
  20. for slot = 1, 16 do
  21. turtle.select(slot)
  22. local itemDetail = turtle.getItemDetail()
  23. if itemDetail and isTrash(itemDetail.name) then
  24. turtle.dropDown()
  25. end
  26. end
  27. end
  28.  
  29. -- Function to ensure the block in front is cleared before moving forward
  30. local function ensureClearAhead()
  31. while turtle.detect() do
  32. turtle.dig()
  33. dropTrash() -- Check for trash after digging a block
  34. sleep(0.5) -- Small delay to allow any falling blocks to settle
  35. end
  36. end
  37.  
  38. -- Function to dig straight down in one column
  39. local function digColumn(depth)
  40. for d = 1, depth do
  41. -- Dig down and move down
  42. if turtle.detectDown() then
  43. turtle.digDown()
  44. dropTrash() -- Check for trash after digging a block
  45. end
  46. turtle.down()
  47.  
  48. -- Avoid bedrock
  49. local success, data = turtle.inspectDown()
  50. if success and data.name == "minecraft:bedrock" then
  51. return false
  52. end
  53. end
  54. return true
  55. end
  56.  
  57. -- Function to return to the top of the column
  58. local function returnToTop(depth)
  59. for i = 1, depth do
  60. turtle.up()
  61. end
  62. end
  63.  
  64. -- Function to dig a quarry straight down
  65. local function quarry(width, length, depth)
  66. local x, z = 0, 0 -- Track position within the quarry
  67.  
  68. for l = 1, length do
  69. for w = 1, width do
  70. local continue = digColumn(depth)
  71. if not continue then
  72. return
  73. end
  74.  
  75. returnToTop(depth)
  76.  
  77. -- Move to the next position
  78. if w < width then
  79. ensureClearAhead() -- Ensure the next column is clear
  80. turtle.forward()
  81. x = x + 1
  82. end
  83. end
  84.  
  85. -- Move to the next row
  86. if l < length then
  87. if l % 2 == 1 then
  88. turtle.turnRight()
  89. ensureClearAhead() -- Ensure the next column is clear
  90. turtle.forward()
  91. turtle.turnRight()
  92. z = z + 1
  93. else
  94. turtle.turnLeft()
  95. ensureClearAhead() -- Ensure the next column is clear
  96. turtle.forward()
  97. turtle.turnLeft()
  98. z = z + 1
  99. end
  100. end
  101. end
  102. end
  103.  
  104. -- Get quarry dimensions from the user
  105. print("Enter quarry width:")
  106. local width = tonumber(read())
  107.  
  108. print("Enter quarry length:")
  109. local length = tonumber(read())
  110.  
  111. print("Enter quarry depth:")
  112. local depth = tonumber(read())
  113.  
  114. -- Run the quarry function with user-provided dimensions
  115. quarry(width, length, depth)
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement