Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- bridge_and_stop.lua
- -- Moves forward, checks below; if air then places stone bricks below and moves forward.
- -- If below is NOT air, stops. Also stops if blocked ahead or out of bricks.
- local function selectStoneBricks()
- for slot = 1, 16 do
- local item = turtle.getItemDetail(slot)
- if item then
- if item.name == "minecraft:stone_bricks" then
- turtle.select(slot)
- return true
- end
- -- Fallback match by display name
- if item.displayName and item.displayName:lower():find("stone bricks") then
- turtle.select(slot)
- return true
- end
- end
- end
- return false
- end
- while true do
- -- First forward; stop if blocked.
- if not turtle.forward() then
- print("Blocked ahead. Stopping.")
- break
- end
- -- Look down: if air, place bricks; else stop.
- if not turtle.detectDown() then
- if not selectStoneBricks() then
- print("Out of stone bricks. Stopping.")
- break
- end
- if not turtle.placeDown() then
- print("Failed to place block below. Stopping.")
- break
- end
- else
- print("Ground detected below. Stopping.")
- break
- end
- end
- print("Done.")
Advertisement
Add Comment
Please, Sign In to add comment