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.
36 lines
771 B
36 lines
771 B
local robot = require("robot")
|
|
local depth,width = ...
|
|
|
|
if not depth or not width then
|
|
print("Usage: farm <forward> <left>")
|
|
return
|
|
end
|
|
|
|
print("Farming in a " .. depth .. "x" .. width .. " area")
|
|
|
|
for _ = 1,width do
|
|
-- break
|
|
for _ = 1,depth do
|
|
if robot.detectDown() then
|
|
robot.swingDown()
|
|
end
|
|
while not robot.forward() do end
|
|
end
|
|
robot.turnAround()
|
|
-- go back and place
|
|
for _ = 1,depth do
|
|
while not robot.forward() do end
|
|
robot.placeDown()
|
|
end
|
|
-- advance to next row
|
|
robot.turnRight()
|
|
while not robot.forward() do end
|
|
robot.turnRight()
|
|
end
|
|
-- go back to starting position
|
|
robot.turnRight()
|
|
for _ = 1,width do
|
|
while not robot.forward() do end
|
|
end
|
|
robot.turnLeft()
|