Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function doFuel()
- while turtle.getFuelLevel() < 10 do
- for i = 1,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- if turtle.refuel(4) then
- break
- end
- end
- end
- if turtle.getFuelLevel() >= 10 then
- break
- end
- print("Please insert more fuel")
- os.pullEvent("turtle_inventory")
- end
- end
- local function putDown()
- if not turtle.detectDown() and not turtle.placeDown() then
- while not turtle.detectDown() do
- for i = 1,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- if turtle.placeDown() then
- break
- end
- end
- end
- if turtle.detectDown() then
- break
- end
- print("Please insert building material.")
- os.pullEvent("turtle_inventory")
- end
- end
- end
- local args = {...}
- if #args ~= 1 or not tonumber(args[1]) then
- print("Usage: bridge <length>")
- return
- end
- local length = tonumber(args[1])
- maxHeight = 0
- minHeight = 0
- height = 0
- for i = 1,length-1 do
- doFuel()
- while turtle.detect() do
- height = height + 1
- while not turtle.up() do
- turtle.back()
- i = i-1
- end
- end
- turtle.forward()
- end
- maxHeight = height+1
- while not turtle.detectDown() do
- doFuel()
- height = height - 1
- turtle.down()
- end
- minHeight = height
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1, length do
- if i < length then
- doFuel()
- if length-i <= maxHeight-1 then
- if height > 1 then
- turtle.down()
- height = height - 1
- end
- else
- if height < maxHeight then
- turtle.up()
- height = height + 1
- end
- end
- putDown()
- turtle.forward()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment