ade_talon

Netherite Mining Turtle

Oct 13th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | Gaming | 0 0
  1. -- Define functions for the tasks
  2. function digAndEject()
  3.     -- Dig forward 3 blocks and eject the first slot item after each dig
  4.     for i = 1, 3 do
  5.         turtle.dig()
  6.         turtle.dropUp(1)  -- Eject the item in the first slot upwards
  7.         turtle.forward()
  8.     end
  9. end
  10.  
  11. function placeItemBehind()
  12.     -- Turn around to face the back
  13.     turtle.turnRight()
  14.     turtle.turnRight()
  15.  
  16.     -- Look for an item in any slot except #1 and place it behind the turtle
  17.     for i = 2, 16 do
  18.         if turtle.getItemCount(i) > 0 then
  19.             turtle.select(i)
  20.             turtle.place()
  21.             break  -- Exit the loop after placing one item
  22.         end
  23.     end
  24.  
  25.     -- Turn back to the original direction
  26.     turtle.turnRight()
  27.     turtle.turnRight()
  28. end
  29.  
  30. function isInventoryEmpty()
  31.     -- Check if all slots except the first are empty
  32.     for i = 2, 16 do
  33.         if turtle.getItemCount(i) > 0 then
  34.             return false
  35.         end
  36.     end
  37.     return true
  38. end
  39.  
  40. -- Main loop: repeat until the inventory (except slot #1) is empty
  41. while not isInventoryEmpty() do
  42.     digAndEject()
  43.     placeItemBehind()
  44. end
  45.  
  46. -- Move back to the last placed block
  47. for i = 1, 3 do
  48.     turtle.back()
  49. end
  50.  
  51. -- Set redstone signal to true on all sides
  52. redstone.setOutput("left", true)
  53. redstone.setOutput("right", true)
  54. redstone.setOutput("back", true)
  55. redstone.setOutput("front", true)
  56. redstone.setOutput("top", true)
  57. redstone.setOutput("bottom", true)
  58.  
  59. -- Completion message
  60. print("Task complete. Redstone signal is active.")
  61.  
Add Comment
Please, Sign In to add comment