Allow mining (gravel) when returning

master v2
D4VID 12 months ago
parent 4278da52b0
commit e31d0986b8

@ -32,7 +32,7 @@ local function mine_row(length)
robot.turnAround() robot.turnAround()
nav.forward(mined) nav.forward(mined, true)
end end
-- starts facing right, mines rows to the right -- starts facing right, mines rows to the right
@ -53,7 +53,7 @@ local function mine(mine_rows, mine_row_length)
-- go back to start -- go back to start
robot.turnAround() robot.turnAround()
nav.forward(moved_rows) nav.forward(moved_rows, true)
end end
return { return {

@ -2,14 +2,18 @@ local robot = require("robot")
-- Moves forward n blocks. -- Moves forward n blocks.
-- Waits if there is an obstruction -- Waits if there is an obstruction
local function forward(n) local function forward(n, mine)
for _ = 1, n do for _ = 1, n do
while true do while true do
local result, error = robot.forward() local result, error = robot.forward()
if result then if result then
break break
else else
print("Cannot move: " .. error) if mine and error == "solid" then
robot.swing()
else
print("Cannot move: " .. error)
end
end end
end end
end end

Loading…
Cancel
Save