Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local distance = tonumber(args[1])
- local torches = 2
- local cobblestone = 3
- local function refuel()
- if turtle.getFuelLevel() == 0 then
- local prev = turtle.getSelectedSlot()
- turtle.select(1)
- if not turtle.refuel(1) then
- print('Need more fuel')
- while not turtle.refuel(1) do
- sleep(1)
- end
- end
- turtle.select(prev)
- end
- end
- local function tryForwards()
- refuel()
- while not turtle.forward() do
- if turtle.detect() then
- turtle.dig()
- end
- sleep(0.5)
- end
- end
- local function tryDown()
- refuel()
- while not turtle.down() do
- if turtle.detectDown() then
- turtle.digDown()
- end
- sleep(0.5)
- end
- end
- local function tryUp()
- refuel()
- while not turtle.up() do
- if turtle.detectUp() then
- turtle.digUp()
- end
- sleep(0.5)
- end
- end
- local function placeTorch()
- local prev = turtle.getSelectedSlot()
- turtle.select(torches)
- turtle.place()
- turtle.select(prev)
- end
- local function placeBlock()
- local prev = turtle.getSelectedSlot()
- turtle.select(cobblestone)
- turtle.placeDown()
- turtle.select(prev)
- end
- local function clearSection(currDistance)
- tryForwards()
- if not turtle.detectDown() then
- placeBlock()
- end
- if currDistance % 6 == 0 then
- turtle.turnRight()
- turtle.turnRight()
- placeTorch()
- turtle.turnRight()
- turtle.turnRight()
- end
- tryUp()
- turtle.turnLeft()
- tryForwards()
- turtle.turnLeft()
- tryForwards()
- tryForwards()
- tryDown()
- turtle.turnRight()
- turtle.turnRight()
- if not turtle.detectDown() then
- placeBlock()
- end
- tryForwards()
- if not turtle.detectDown() then
- placeBlock()
- end
- end
- turtle.select(1)
- turtle.turnRight()
- for i = 1, distance, 1 do
- clearSection(i)
- end
- turtle.dig()
- turtle.turnRight()
- turtle.up()
- for i = 1, distance, 1 do
- tryForwards()
- end
- tryDown()
- for i = 3, 16, 1 do
- turtle.select(i)
- turtle.drop()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement