Mine around turtle at each shaft step
This commit is contained in:
parent
aea4b4044a
commit
9ad825fc60
1 changed files with 53 additions and 0 deletions
|
@ -224,6 +224,56 @@ function find_next_shaft()
|
|||
end
|
||||
end
|
||||
|
||||
function is_block_precious(block)
|
||||
local WORTHY_BLOCKS = {
|
||||
{ name = 'minecraft:coal_ore' },
|
||||
{ name = 'minecraft:iron_ore' },
|
||||
{ name = 'minecraft:gold_ore' },
|
||||
{ name = 'minecraft:lapis_ore' },
|
||||
{ name = 'minecraft:redstone_ore' },
|
||||
{ name = 'minecraft:diamond_ore' },
|
||||
{ name = 'minecraft:emerald_ore' },
|
||||
{ name = 'ic2:resource', state_type = 'lead_ore' },
|
||||
{ name = 'ic2:resource', state_type = 'copper_ore' },
|
||||
{ name = 'ic2:resource', state_type = 'tin_ore' },
|
||||
{ name = 'ic2:resource', state_type = 'uranium_ore' },
|
||||
}
|
||||
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
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Mine worthy blocks around the current turtle position
|
||||
function mine_around()
|
||||
exists, details = turtle.inspectUp()
|
||||
if exists and is_block_precious(details) then
|
||||
turtle.digUp()
|
||||
end
|
||||
|
||||
exists, details = turtle.inspectDown()
|
||||
if exists and is_block_precious(details) then
|
||||
turtle.digDown()
|
||||
end
|
||||
|
||||
for lookat=1,3,2 do -- lookat in {1,3}
|
||||
turn_abs(lookat)
|
||||
exists, details = turtle.inspect()
|
||||
if exists and is_block_precious(details) then
|
||||
turtle.dig()
|
||||
end
|
||||
end
|
||||
turn_abs(0)
|
||||
end
|
||||
|
||||
-- Mine a new shaft in front of the turtle
|
||||
function mine_shaft()
|
||||
turn_abs(0)
|
||||
|
@ -231,7 +281,10 @@ function mine_shaft()
|
|||
while turtle.detect() do
|
||||
turtle.dig()
|
||||
end
|
||||
|
||||
move_forward()
|
||||
|
||||
mine_around()
|
||||
end
|
||||
turn_abs(2)
|
||||
while depth > 0 do
|
||||
|
|
Loading…
Add table
Reference in a new issue