|
|
@ -2,18 +2,22 @@ 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
|
|
|
|
|
|
|
|
if mine and error == "solid" then
|
|
|
|
|
|
|
|
robot.swing()
|
|
|
|
else
|
|
|
|
else
|
|
|
|
print("Cannot move: " .. error)
|
|
|
|
print("Cannot move: " .. error)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Move until it runs into a solid block.
|
|
|
|
-- Move until it runs into a solid block.
|
|
|
|
-- Waits if there is an entity obstrucion
|
|
|
|
-- Waits if there is an entity obstrucion
|
|
|
|