You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
955 B

local robot = require("robot")
return {
forward = function(n)
if not n then n = 1 end
for _ = 1, n do
while not robot.forward() do
local result, desc = robot.detect()
if result and desc == "solid" then
robot.swing()
end
end
end
end,
back = function(n)
if not n then n = 1 end
for _ = 1, n do
while not robot.back() do end
end
end,
up = function(n)
if not n then n = 1 end
for _ = 1, n do
while not robot.up() do
local result, desc = robot.detectUp()
if result and desc == "solid" then
robot.swingUp()
end
end
end
end,
down = function(n)
if not n then n = 1 end
for _ = 1, n do
while not robot.down() do end
end
end,
}