Mine: tryhard forward
This commit is contained in:
parent
99d6aeb35e
commit
fef74033d5
1 changed files with 27 additions and 4 deletions
|
@ -70,10 +70,17 @@ function _count_move_dir(dir)
|
|||
end
|
||||
end
|
||||
|
||||
function move_forward()
|
||||
function move_forward(will_retry)
|
||||
rc, desc = turtle.forward()
|
||||
if not rc then abort("Move: "..desc) end
|
||||
if not rc then
|
||||
if will_retry then
|
||||
return false
|
||||
else
|
||||
abort("Move: "..desc)
|
||||
end
|
||||
end
|
||||
_count_move_dir(facing)
|
||||
return true
|
||||
end
|
||||
function move_back()
|
||||
rc, desc = turtle.back()
|
||||
|
@ -91,6 +98,20 @@ function move_down()
|
|||
height = height - 1
|
||||
end
|
||||
|
||||
function tryhard_forward()
|
||||
for i=1,5 do
|
||||
while turtle.detect() do
|
||||
turtle.dig()
|
||||
end
|
||||
if move_forward(true) then
|
||||
return true
|
||||
else
|
||||
sleep(1)
|
||||
end
|
||||
end
|
||||
abort('Giving up trying to move forward.')
|
||||
end
|
||||
|
||||
function go_to_depth(dd)
|
||||
turn_abs(0)
|
||||
while depth > dd do
|
||||
|
@ -285,9 +306,11 @@ function mine_shaft()
|
|||
turtle.dig()
|
||||
end
|
||||
|
||||
move_forward()
|
||||
tryhard_forward()
|
||||
|
||||
mine_around()
|
||||
if depth > 1 then -- if not we confuse find_next_shaft
|
||||
mine_around()
|
||||
end
|
||||
end
|
||||
turn_abs(2)
|
||||
while depth > 0 do
|
||||
|
|
Loading…
Reference in a new issue