--Pastebin name: tUFHwJn3
--Position this device in the branch tunnel
local tArgs = { ... } -- obtain tunnel length and turn around options
if #tArgs ~= 2 then
print( "Usage: tunnel <length>, and then turn around: <y> or <n>" )
return
end
local length = tonumber( tArgs[1] ) -- Check if the tunnel length is > 1
if length < 1 then
print( "Tunnel length must be positive" )
return
end
local turn = ( tArgs[2] ) -- Check if the turtle turn around option is y or n
if not( turn ~= ( "y" ) or turn ~= ( "n" )) then
print( "Indicate whether to have the turtle go down to the next course and turn around" )
return
end
local fuel = turtle.getFuelLevel()
if fuel < 80 then
print("you must add more fuel")
return
end
--definition of functions follows
local function tryDig() -- This function digs forward one block
while turtle.detect() do
if turtle.dig() then
sleep(0.5)
else
return false
end
end
return true
end
local function tryDigUp() -- This function digs up one block
while turtle.detectUp() do
if turtle.digUp() then
sleep(0.5)
else
return false
end
end
return true
end
local function tryDigDown() -- This function digs down one block
while turtle.detectDown() do
if turtle.digUp() then
sleep(0.5)
else
return false
end
end
return true
end
Comments