mercwear

CC Place and Break

Mar 31st, 2025 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. print("Press CTRL+T to stop")
  2. local turtle_inventory_slot = 1
  3. while true do --Always loop
  4. local result, message = turtle.suckDown(1) --Try to pull in item from chest below
  5. local item_count, item_name = turtle.getItemDetail(turtle_inventory_slot) --Get count and name of selected turtle inventory item
  6. if item_count <= 0 then --Turtle no longer has inventory in selected spot select next spot
  7. if turtle_inventory_slot > 16 then --End of turtle inventory reached stop NEED TO MAKE THIS BETTER
  8. print("Reached end of turtle inventory, stopping.")
  9. return
  10. end
  11. if turtle_inventory_slot <= 16 then
  12. turtle.select(turtle_inventory_slot)
  13. local item_count, item_name = turtle.getItemDetail(turtle_inventory_slot)
  14. while item_name ~= "minecraft:netherrack" then
  15. turtle.dropUp()
  16. turtle_inventory_slot = turtle_inventory_slot + 1
  17. if turtle_inventory_slot <= 16 then
  18. return
  19. end
  20. turtle.select(turtle_inventory_slot)
  21. local item_count, item_name = turtle.getItemDetail(turtle_inventory_slot)
  22.  
  23. end
  24. end
  25. --Check if item is correct to drop
  26. if item_name ~= "minecraft:netherrack" then
  27. turtle.dropUp() --Drop the incorrect item so the vacuum chest grabs it
  28. turtle_inventory_slot = turtle_inventory_slot + 1
  29. if turtle_inventory_slot >= 17 then --End of turtle inventory reached stop NEED TO MAKE THIS BETTER
  30. print("Reached end of turtle inventory, stopping.")
  31. return
  32. end
  33. turtle.select(turtle_inventory_slot)
  34. end
  35. local block_present, info = turtle.inspect()
  36. --print(block_present)
  37. if block_present then
  38. --print("Found block, mining!")
  39. if info.name ~= "minecraft:netherrack" then
  40. turtle.dig()
  41. end
  42. end
  43. if block_present == false then
  44. --print("No block found, placing block.")
  45. turtle.place(0)
  46. end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment