Compare commits
2 commits
d7c8e4826f
...
fef74033d5
Author | SHA1 | Date | |
---|---|---|---|
Théophile Bastian | fef74033d5 | ||
Théophile Bastian | 99d6aeb35e |
|
@ -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
|
||||
|
@ -240,11 +261,14 @@ function is_block_precious(block)
|
|||
}
|
||||
if block then
|
||||
for id, refblock in ipairs(WORTHY_BLOCKS) do
|
||||
if block['name'] == refblock['name'] then
|
||||
if (refblock['state_type']
|
||||
and block['state'] and block['state']['type']
|
||||
and block['state']['type'] == refblock['state_type']) then
|
||||
if block.name == refblock.name then
|
||||
if refblock.state_type then
|
||||
if (block.state and block.state.type
|
||||
and block.state.type == refblock.state_type) then
|
||||
return true
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -282,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