From a8eb6b00ac278a0870a3a1d5d138d21f7acdb9ed Mon Sep 17 00:00:00 2001 From: D4VID Date: Mon, 30 Sep 2024 17:37:52 +0200 Subject: [PATCH] Begin farming --- farm.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 farm.lua 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()