Mine: find shaft: mine whole lobby
This commit is contained in:
parent
b98f3a8e0c
commit
c254339760
1 changed files with 48 additions and 39 deletions
|
@ -24,6 +24,10 @@ FUEL_LOW = 1000
|
||||||
|
|
||||||
SHAFT_DEPTH = 100
|
SHAFT_DEPTH = 100
|
||||||
|
|
||||||
|
-- Start at this position to find the next shaft
|
||||||
|
next_shaft_side = 0
|
||||||
|
next_shaft_height = 0
|
||||||
|
|
||||||
function distance_to_drop()
|
function distance_to_drop()
|
||||||
return math.abs(depth - DROP_POINT_D)
|
return math.abs(depth - DROP_POINT_D)
|
||||||
+ math.abs(height - DROP_POINT_H)
|
+ math.abs(height - DROP_POINT_H)
|
||||||
|
@ -165,54 +169,57 @@ end
|
||||||
|
|
||||||
-- Find the next unmined shaft and end up in front of it
|
-- Find the next unmined shaft and end up in front of it
|
||||||
function find_next_shaft()
|
function find_next_shaft()
|
||||||
go_to(0, 0, 0)
|
function is_shaft_pos()
|
||||||
|
if side % 2 == 1 then
|
||||||
|
return false
|
||||||
|
elseif side % 4 == 0 then
|
||||||
|
return height % 3 == 0
|
||||||
|
elseif side % 4 == 2 then
|
||||||
|
return height % 3 ~= 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function is_shaft()
|
||||||
|
return is_shaft_pos() and turtle.detect()
|
||||||
|
end
|
||||||
|
|
||||||
|
go_to(next_shaft_height, 0, next_shaft_side)
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
for hei=1,MAX_HEIGHT-1 do
|
if side % 2 == 0 then
|
||||||
if (height % 3) == 0 then
|
while height < MAX_HEIGHT - 1 do
|
||||||
if turtle.detect() then
|
if is_shaft() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if turtle.detectUp() then
|
if turtle.detectUp() then
|
||||||
turtle.digUp()
|
turtle.digUp()
|
||||||
end
|
end
|
||||||
move_up()
|
move_up()
|
||||||
end
|
end
|
||||||
if turtle.detect() then
|
if is_shaft() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
else
|
||||||
turn_abs(1)
|
while height > 0 do
|
||||||
for i=0,1 do
|
if is_shaft() then
|
||||||
if turtle.detect() then
|
|
||||||
turtle.dig()
|
|
||||||
end
|
|
||||||
move_forward()
|
|
||||||
end
|
|
||||||
turn_abs(0)
|
|
||||||
|
|
||||||
for hei=MAX_HEIGHT-1,1,-1 do
|
|
||||||
if (height % 3) ~= 0 then
|
|
||||||
if turtle.detect() then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if turtle.detectDown() then
|
if turtle.detectDown() then
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
end
|
end
|
||||||
move_down()
|
move_down()
|
||||||
end
|
end
|
||||||
|
if is_shaft() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
turn_abs(1)
|
turn_abs(1)
|
||||||
for i=0,1 do
|
|
||||||
if turtle.detect() then
|
if turtle.detect() then
|
||||||
turtle.dig()
|
turtle.dig()
|
||||||
end
|
end
|
||||||
move_forward()
|
move_forward()
|
||||||
end
|
|
||||||
turn_abs(0)
|
turn_abs(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -234,6 +241,8 @@ function main()
|
||||||
while true do
|
while true do
|
||||||
print("Finding shaft")
|
print("Finding shaft")
|
||||||
find_next_shaft()
|
find_next_shaft()
|
||||||
|
next_shaft_height = height
|
||||||
|
next_shaft_side = side
|
||||||
print("Mining shaft at position:")
|
print("Mining shaft at position:")
|
||||||
_dump_pos()
|
_dump_pos()
|
||||||
mine_shaft()
|
mine_shaft()
|
||||||
|
|
Loading…
Reference in a new issue