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
|
||||||
end
|
end
|
||||||
|
|
||||||
function move_forward()
|
function move_forward(will_retry)
|
||||||
rc, desc = turtle.forward()
|
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)
|
_count_move_dir(facing)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
function move_back()
|
function move_back()
|
||||||
rc, desc = turtle.back()
|
rc, desc = turtle.back()
|
||||||
|
@ -91,6 +98,20 @@ function move_down()
|
||||||
height = height - 1
|
height = height - 1
|
||||||
end
|
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)
|
function go_to_depth(dd)
|
||||||
turn_abs(0)
|
turn_abs(0)
|
||||||
while depth > dd do
|
while depth > dd do
|
||||||
|
@ -240,11 +261,14 @@ function is_block_precious(block)
|
||||||
}
|
}
|
||||||
if block then
|
if block then
|
||||||
for id, refblock in ipairs(WORTHY_BLOCKS) do
|
for id, refblock in ipairs(WORTHY_BLOCKS) do
|
||||||
if block['name'] == refblock['name'] then
|
if block.name == refblock.name then
|
||||||
if (refblock['state_type']
|
if refblock.state_type then
|
||||||
and block['state'] and block['state']['type']
|
if (block.state and block.state.type
|
||||||
and block['state']['type'] == refblock['state_type']) then
|
and block.state.type == refblock.state_type) then
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -282,9 +306,11 @@ function mine_shaft()
|
||||||
turtle.dig()
|
turtle.dig()
|
||||||
end
|
end
|
||||||
|
|
||||||
move_forward()
|
tryhard_forward()
|
||||||
|
|
||||||
mine_around()
|
if depth > 1 then -- if not we confuse find_next_shaft
|
||||||
|
mine_around()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
turn_abs(2)
|
turn_abs(2)
|
||||||
while depth > 0 do
|
while depth > 0 do
|
||||||
|
|
Loading…
Reference in a new issue