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()
nav.forward(mined)
nav.forward(mined, true)
end
-- starts facing right, mines rows to the right
@ -53,7 +53,7 @@ local function mine(mine_rows, mine_row_length)
-- go back to start
robot.turnAround()
nav.forward(moved_rows)
nav.forward(moved_rows, true)
end
return {

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

Loading…
Cancel
Save