robathome

MC line_dropper

Nov 4th, 2025 (edited)
582
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. end
  29.  
  30. -- Look down: if air, place bricks; else stop.
  31. if not turtle.detectDown() then
  32. if not selectStoneBricks() then
  33. print("Out of stone bricks. Stopping.")
  34. break
  35. end
  36. if not turtle.placeDown() then
  37. print("Failed to place block below. Stopping.")
  38. break
  39. end
  40. else
  41. print("Ground detected below. Stopping.")
  42. break
  43. end
  44. end
  45.  
  46. print("Done.")
  47.  
Advertisement
Add Comment
Please, Sign In to add comment