Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bridgePos = 0
- function selectBlock(block)
- currentSelectedBlock = turtle.getItemDetail()
- if currentSelectedBlock ~= block then
- for i = 1, 16 do
- iBlockDetail = turtle.getItemDetail(i)
- if iBlockDetail ~= nil then
- if iBlockDetail.name == block then
- turtle.select(i)
- break
- end
- end
- if i == 16 then
- error("oh noes " .. block .. " ran out")
- end
- end
- end
- end
- function forwardDig()
- blockInFront, blockInspect = turtle.inspect()
- if blockInFront then
- turtle.dig()
- end
- turtle.forward()
- end
- function downDig()
- blockDown, blockInspect = turtle.inspectDown()
- if blockDown then
- turtle.digDown()
- end
- turtle.down()
- end
- function upDig()
- blockUp, blockInspect = turtle.inspectUp()
- if blockUp then
- turtle.digUp()
- end
- turtle.up()
- end
- function placePillar()
- for i = 1, 2 do
- turtle.down()
- end
- turtle.forward()
- selectBlock("minecraft:stone_brick_stairs")
- turtle.placeUp()
- for i = 1, 2 do
- turtle.forward()
- end
- for i = 1, 2 do
- turtle.turnRight()
- end
- turtle.placeUp()
- turtle.forward()
- selectBlock("minecraft:stonebrick")
- turtle.placeUp()
- repeat
- blockBelow = turtle.inspectDown()
- if blockBelow ~= nil then
- turtle.down()
- turtle.placeUp()
- while blockBelow ~= nil
- turtle.forward()
- for i = 1, 2 do
- turtle.turnRight()
- end
- turtle.place()
- repeat
- blockAbove = turtle.inspectUp()
- if blockAbove ~= nil then
- turtle.up()
- while blockAbove ~= nil
- turtle.back()
- for i = 1, 2 do
- turtle.up()
- end
- end
- function placePillars()
- placePillar()
- turtle.turnRight()
- for i = 1, 4 do
- turtle.forward()
- end
- turtle.turnLeft()
- placePillar()
- turtle.turnLeft()
- for i = 1, 4 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function placeTorch()
- turtle.up()
- turtle.turnRight()
- for i = 1, 3 do
- turtle.forward()
- end
- turtle.turnRight()
- selectBlock("minecraft:torch")
- turtle.place()
- turtle.turnRight()
- for i = 1, 3 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.down()
- end
- function placeBridgeChunk()
- for i = 1, 2 do
- turtle.turnRight()
- end
- turtle.up()
- selectBlock("minecraft:stonebrick")
- if bridgePos % 2 == 0 then
- turtle.up()
- turtle.place()
- turtle.down()
- end
- turtle.place()
- turtle.down()
- turtle.turnLeft()
- for i = 1, 7 do
- turtle.turnRight()
- turtle.place()
- turtle.turnLeft()
- turtle.forward()
- end
- turtle.down()
- for i = 1, 2 do
- turtle.turnRight()
- end
- turtle.forward()
- for i = 1, 2 do
- turtle.up()
- end
- turtle.turnLeft()
- turtle.place()
- if bridgePos % 2 == 0 then
- turtle.up()
- turtle.place()
- turtle.down()
- end
- for i = 1, 2 do
- turtle.down()
- end
- turtle.turnRight()
- turtle.forward()
- for i = 1, 4 do
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- turtle.forward()
- end
- turtle.place()
- turtle.turnLeft()
- turtle.down()
- turtle.place()
- turtle.turnLeft()
- for i = 1, 4 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.place()
- if bridgePos % 5 == 0 then
- placePillars()
- end
- turtle.turnRight()
- for i = 1, 2 do
- turtle.up()
- end
- for i = 1, 5 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function clearSpace()
- turtle.turnRight()
- for i = 1, 3 do
- upDig()
- end
- for i = 1, 6 do
- for j = 1, 6 do
- forwardDig()
- end
- for j = 1, 2 do
- turtle.turnRight()
- end
- downDig()
- end
- for i = 1, 3 do
- turtle.up()
- end
- turtle.turnLeft()
- end
- function buildChunkOfBridge()
- forwardDig()
- clearSpace()
- placeBridgeChunk()
- if (bridgePos + 3) % 8 == 0 then
- placeTorch()
- end
- bridgePos = bridgePos + 1
- end
- function checkFuel()
- fuelLevel = turtle.getFuelLevel()
- if fuelLevel < 50 then
- for i = 1, 16 do
- turtle.select(i)
- turtle.refuel(64)
- end
- end
- end
- function mainLoop()
- while true do
- checkFuel()
- buildChunkOfBridge()
- end
- end
- mainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement