commit a8eb6b00ac278a0870a3a1d5d138d21f7acdb9ed Author: D4VID Date: Mon Sep 30 17:37:52 2024 +0200 Begin farming diff --git a/farm.lua b/farm.lua new file mode 100644 index 0000000..a665154 --- /dev/null +++ b/farm.lua @@ -0,0 +1,35 @@ +local robot = require("robot") +local depth,width = ... + +if not depth or not width then + print("Usage: farm ") + 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()