Advertisement
Maxello_

tutel test3

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