while not turtle.forward() do turtle.dig() endbasically I am telling it to loop through the code between the 'do' and the 'end' as long as the turtle.forward() command returns false or nothing
local function tunnel(length,torches) turtle.select(1) --select slot 1 where the torches are for done=1,tonumber(length) do while not turtle.forward() do turtle.dig() end --keep calling the forward function and every time it fails dig, if it succeeds then end (for gravel) while turtle.detectUp() do turtle.digUp() end --as long as something is above the turtle dig it out, once nothing is there end (for gravel) if torches~='' and done%tonumber(torches)==0 then turtle.back() turtle.placeUp() turtle.forward() end --if torches is not a blank string (what the read command returns when they enter nothing) then check if the amount of the tunnel done is divisible by 5, if it is devisible then move back and place a torch and move forward again end turtle.turnLeft() turtle.turnLeft() for done=1,tonumber(length) do while not turtle.forward() do turtle.dig() end --move back along the tunnel, digging out anything in the way (for gravel) end turtle.turnRight() for slot=2,16 do turtle.select(slot) turtle.drop() end turtle.turnRight() return true end term.clear() term.setCursorPos(1,1) print('How long should your tunnel be?') write('length: ') local len=read() print('how often should torches be placed (blank for none)') local torches=read() tunnel(len,torches)
if there is still anything you do not understand feel free to ask