Advertisement
Maxello_

tutel testv2

Aug 22nd, 2024 (edited)
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 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 deposit items into a chest above the turtle
  19. local function depositItems()
  20. for slot = 2, 16 do -- Start from slot 2 since slot 1 has the chest
  21. turtle.select(slot)
  22. local itemDetail = turtle.getItemDetail()
  23. if itemDetail then
  24. if isTrash(itemDetail.name) then
  25. turtle.dropDown() -- Dispose of trash items
  26. else
  27. turtle.dropUp() -- Deposit other items in chest above
  28. end
  29. end
  30. end
  31. end
  32.  
  33. -- Function to check if the inventory is full
  34. local function isInventoryFull()
  35. for slot = 2, 16 do -- Check from slot 2 to avoid overriding the chest in slot 1
  36. if turtle.getItemCount(slot) == 0 then
  37. return false
  38. end
  39. end
  40. return true
  41. end
  42.  
  43. -- Function to place a chest above the turtle and deposit items
  44. local function placeChestAndDeposit()
  45. turtle.select(1)
  46. if turtle.getItemDetail() and turtle.getItemDetail().name == "minecraft:chest" then
  47. if turtle.detectUp() then
  48. turtle.digUp() -- Ensure space is clear for the chest
  49. end
  50. turtle.placeUp()
  51. depositItems()
  52. else
  53. print("No chest found in the first slot! Please place a chest in slot 1 and type 'y' to continue.")
  54. repeat
  55. local input = read()
  56. until input == "y"
  57. end
  58. end
  59.  
  60. -- Function to dig straight down in one column
  61. local function digColumn(depth)
  62. for d = 1, depth do
  63. if isInventoryFull() then
  64. placeChestAndDeposit()
  65. end
  66.  
  67. -- Dig down and move down
  68. if turtle.detectDown() then
  69. turtle.digDown()
  70. end
  71. turtle.down()
  72.  
  73. -- Avoid bedrock
  74. local success, data = turtle.inspectDown()
  75. if success and data.name == "minecraft:bedrock" then
  76. return false
  77. end
  78. end
  79. return true
  80. end
  81.  
  82. -- Function to return to the top of the column
  83. local function returnToTop(depth)
  84. for i = 1, depth do
  85. turtle.up()
  86. end
  87. end
  88.  
  89. -- Function to dig a quarry straight down
  90. local function quarry(width, length, depth)
  91. local x, z = 0, 0 -- Track position within the quarry
  92.  
  93. for l = 1, length do
  94. for w = 1, width do
  95. local continue = digColumn(depth)
  96. if not continue then
  97. return
  98. end
  99.  
  100. returnToTop(depth)
  101.  
  102. -- Move to the next position
  103. if w < width then
  104. turtle.dig()
  105. turtle.forward()
  106. x = x + 1
  107. end
  108. end
  109.  
  110. -- Move to the next row
  111. if l < length then
  112. if l % 2 == 1 then
  113. turtle.turnRight()
  114. turtle.dig()
  115. turtle.forward()
  116. turtle.turnRight()
  117. z = z + 1
  118. else
  119. turtle.turnLeft()
  120. turtle.dig()
  121. turtle.forward()
  122. turtle.turnLeft()
  123. z = z + 1
  124. end
  125. end
  126. end
  127. end
  128.  
  129. -- Function to check if a chest is in the first slot before starting
  130. local function checkChest()
  131. turtle.select(1)
  132. if not turtle.getItemDetail() or turtle.getItemDetail().name ~= "minecraft:chest" then
  133. print("No chest found in the first slot! Please place a chest in slot 1 and type 'y' to start.")
  134. repeat
  135. local input = read()
  136. until input == "y"
  137. end
  138. end
  139.  
  140. -- Get quarry dimensions from the user
  141. print("Enter quarry width:")
  142. local width = tonumber(read())
  143.  
  144. print("Enter quarry length:")
  145. local length = tonumber(read())
  146.  
  147. print("Enter quarry depth:")
  148. local depth = tonumber(read())
  149.  
  150. -- Check for chest in the first slot
  151. checkChest()
  152.  
  153. -- Run the quarry function with user-provided dimensions
  154. quarry(width, length, depth)
  155.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement