From da931b0e3dc187443e6844a916a6f211b6575788 Mon Sep 17 00:00:00 2001 From: sascham Date: Sun, 20 Dec 2020 21:57:38 +0000 Subject: [PATCH] Initial Commit --- Tree_Farm/treeautofarm.lua | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Tree_Farm/treeautofarm.lua diff --git a/Tree_Farm/treeautofarm.lua b/Tree_Farm/treeautofarm.lua new file mode 100644 index 0000000..3785311 --- /dev/null +++ b/Tree_Farm/treeautofarm.lua @@ -0,0 +1,70 @@ +--[[ +treeautofarm program by The_Lux +This program checks a tree farm with given length and width and +chops the tree down, when it finds one. +]] + +-- In which direction should the farm be automated? +DIRECTION = 'right' +NUM_OF_TREES = 9 +TREE_SAPLING = 'oak' +TREE_DISTANCE = 3 +DISTANCE = 3 +WIDTH = 2 + + -- bring turtle in position + if DIRECTION == 'right' then + turtle.turnRight() + else + turtle.turnLeft() + end + turtle.forward() + if DIRECTION == 'right' then + turtle.turnLeft() + else + turtle.turnRight() + end + +while true do + -- Wait a few minutes + os.sleep(300) + + + for i = 1, WIDTH do + -- Check a line of Trees + shell.run('treeline.lua', NUM_OF_TREES, TREE_DISTANCE, TREE_SAPLING) + + -- Go to the next line. But only, if it isn't the last loop + if i < WIDTH then + if DIRECTION == 'right' then + turtle.turnRight() + else + turtle.turnLeft() + end + for j = 1, DISTANCE do + turtle.forward() + end + if DIRECTION == ' right' then + turtle.turnLeft() + else + turtle.turnRight() + end + end + end + + -- Go back to start + if DIRECTION == 'right' then + turtle.turnRight() + else + turtle.turnLeft() + end + for i = 1, ((WIDTH - 1) * DISTANCE) do + turtle.forward() + end + if DIRECTION == ' right' then + turtle.turnLeft() + else + turtle.turnRight() + end + +end \ No newline at end of file