-- 3 wide bridge v2.0 by SparkVGX --Variables distance = 0 blocksPlaced = 0 fuel = 1 torches = 2 spaceCounter = 7 -- Clears screen for instructions or not function clear(test) -- function to reset screen term.clear() term.setCursorPos(1,1) if test == nil then -- easy way to decide whether to display text or not print("Place me on the ground just in front of where you want the bridge.") print() print("Fuel goes in slot 1, Torches in two, and blocks everywhere else.") print() print("Press any key to start..") end end function anyKey() while not bEnd do local event, key = os.pullEvent("key") if (key ~= 1) and (key ~= 42) then bEnd = true end end end -- If I need fuel, I will try use refuel function checkFuel() if turtle.getFuelLevel() <= 5 then turtle.select(1) --fuel goes in this slot turtle.refuel(1) end end -- Place torch function pTorch() turtle.select(2) turtle.up() turtle.place() turtle.down() end -- Select blocks to place -- only slots 3-16 should have blocks function selectBlock() for slot=3,16 do if turtle.getItemCount(slot)~=0 then turtle.select(slot) break end end end -- Select blocks and place them if possible, otherwise if out of blocks, wait. function placeB() selectBlock() if turtle.detect() == false then if turtle.place() == false then print("Need blocks") sleep(5) placeB() end blocksPlaced = blocksPlaced + 1 end end -- pretty simple.. you turn around function turnAround() turtle.turnLeft() turtle.turnLeft() end --initial start to get turtle in position function runOnce() checkFuel() while turtle.detectDown() == true do turtle.forward() distance = distance + 1 end turtle.down() turtle.turnLeft() placeB() turnAround() placeB() turtle.turnRight() end -- takes the turtle back where it started function goHome() turtle.up() selectBlock() turtle.placeDown() blocksPlaced = blocksPlaced + 1 turtle.up() for i=1,distance do turtle.forward() end turnAround() turtle.down() print("All done!") print("I went " .. distance .. " meters and placed " .. blocksPlaced .. " blocks.") end --The main code to run function start() runOnce() --checks fuel, places blocks behind and on the sides. while turtle.back() do checkFuel() placeB() turtle.turnLeft() placeB() turnAround() placeB() turtle.turnLeft() spaceCounter = spaceCounter + 1 distance = distance + 1 -- every so often, places a torch and -- resets the counter if spaceCounter == 8 then pTorch() spaceCounter = 0 end end -- all done? return to start goHome() end clear() anyKey() start()