mercwear

CC Place and break 2

Apr 1st, 2025 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. local result, message, item_name = 0
  2. local turtle_selected_spot = 1
  3. local block_present, info, item_count = 0
  4.  
  5.  
  6. print("Press CTRL+T to stop")
  7.  
  8.  
  9.  
  10. while true do --Always loop
  11. if turtle_selected_spot == 17 then --No items left in turtle and since we do not have a 17th inventory spot this would cause an error so start back at slot 1
  12. turtle_selected_spot = 1
  13. turtle.select(turtle_selected_spot)
  14. item_details = turtle.getItemDetail(turtle_selected_spot)
  15. if item_details == nil then --No items in slot one so we are probably out of items to place
  16. block_present, info = turtle.inspect() --Check block in front of turtle to see if it needs to be mined before we quit the script
  17. if block_present and info.name ~= "minecraft:netherrack" then
  18. turtle.dig()
  19. end
  20. print("Turtle out of items.")
  21. return
  22. else
  23. if item_details.name ~= "minecraft:netherrack" then --The item in slot one is not netherrack so drop it then quit the script
  24. turtle.dropUp()
  25. block_present, info = turtle.inspect() --Check block in front of turtle to see if it needs to be mined before we quit the script
  26. if block_present and info.name ~= "minecraft:netherrack" then
  27. turtle.dig()
  28. end
  29. print("Turtle out of items.")
  30. return
  31. end
  32. end
  33. end
  34. turtle.select(turtle_selected_spot)
  35. turtle.suckDown() --Pull items from chest below turtle
  36. item_details = turtle.getItemDetail(turtle_selected_spot) --Get count and name of selected turtle inventory item
  37.  
  38. if item_details == nil then --Turtle no longer has inventory in selected spot
  39. turtle_selected_spot = turtle_selected_spot + 1 --Move to next inventory spot
  40. end
  41.  
  42. if item_details ~= nil then --If an item is in the selected slot then get details of that item
  43. if item_details.name ~= "minecraft:netherrack" then --If item is not netherrack then drop it above turtle
  44. turtle.dropUp()
  45. end
  46. if item_details.name == "minecraft:netherrack" then --If the item is netherrack then attempt to place in front of turtle
  47. --Scan block in front of turtle to see if it's empty
  48. block_present, info = turtle.inspect()
  49. if block_present and info.name ~= "minecraft:netherrack" then
  50. turtle.dig()
  51. end
  52. if block_present == false and item_details.name == "minecraft:netherrack" then
  53. turtle.place()
  54. end
  55. end
  56. end
  57. end
Advertisement
Add Comment
Please, Sign In to add comment