Compare commits
4 commits
c254339760
...
f3fdbaad9c
Author | SHA1 | Date | |
---|---|---|---|
Théophile Bastian | f3fdbaad9c | ||
Théophile Bastian | 9ad825fc60 | ||
Nathanaël Courant | aea4b4044a | ||
Nathanaël Courant | 500a0a7b9f |
|
@ -22,7 +22,7 @@ FUEL_POINT_S = 3
|
||||||
FUEL_EXPECTATION = 2000
|
FUEL_EXPECTATION = 2000
|
||||||
FUEL_LOW = 1000
|
FUEL_LOW = 1000
|
||||||
|
|
||||||
SHAFT_DEPTH = 100
|
SHAFT_DEPTH = 5
|
||||||
|
|
||||||
-- Start at this position to find the next shaft
|
-- Start at this position to find the next shaft
|
||||||
next_shaft_side = 0
|
next_shaft_side = 0
|
||||||
|
@ -224,9 +224,76 @@ function find_next_shaft()
|
||||||
end
|
end
|
||||||
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
|
-- Mine a new shaft in front of the turtle
|
||||||
function mine_shaft()
|
function mine_shaft()
|
||||||
turtle.dig()
|
turn_abs(0)
|
||||||
|
while depth < SHAFT_DEPTH do
|
||||||
|
while turtle.detect() do
|
||||||
|
turtle.dig()
|
||||||
|
end
|
||||||
|
|
||||||
|
move_forward()
|
||||||
|
|
||||||
|
mine_around()
|
||||||
|
end
|
||||||
|
turn_abs(2)
|
||||||
|
while depth > 0 do
|
||||||
|
while turtle.detect() do
|
||||||
|
turtle.dig()
|
||||||
|
end
|
||||||
|
move_forward()
|
||||||
|
end
|
||||||
|
turn_abs(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Main function
|
-- Main function
|
||||||
|
|
Loading…
Reference in a new issue