robathome

MC basic dropper

Nov 6th, 2025
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. -- bridge_and_stop.lua
  2. -- Moves forward, checks below; if air then places stone bricks below and moves forward.
  3. -- If below is NOT air, stops. Also stops if blocked ahead or out of bricks.
  4.  
  5. local function selectStoneBricks()
  6. for slot = 1, 16 do
  7. local item = turtle.getItemDetail(slot)
  8. if item then
  9. if item.name == "minecraft:stone_bricks" then
  10. turtle.select(slot)
  11. return true
  12. end
  13. -- Fallback match by display name
  14. if item.displayName and item.displayName:lower():find("stone bricks") then
  15. turtle.select(slot)
  16. return true
  17. end
  18. end
  19. end
  20. return false
  21. end
  22.  
  23. while true do
  24. -- First forward; stop if blocked.
  25. if not turtle.forward() then
  26. print("Blocked ahead. Stopping.")
  27. break
  28. else
  29. if not selectStoneBricks() then
  30. print("Out of stone bricks. Stopping.")
  31. break
  32. end
  33. if not turtle.placeDown() then
  34. print("Failed to place block below. Stopping.")
  35. break
  36. end
  37. -- After placing, move forward once more.
  38. if not turtle.forward() then
  39. print("Blocked after placing. Stopping.")
  40. break
  41. end
  42. end
  43. end
  44.  
  45. print("Done.")
  46.  
Advertisement
Add Comment
Please, Sign In to add comment