From 8f46d225010a031872ad8153c6626ea16663e239 Mon Sep 17 00:00:00 2001 From: Sascha Martens Date: Fri, 6 Nov 2020 16:05:04 +0100 Subject: [PATCH] Added sucking up more areas --- Tree_Farm/choptree.lua | 27 +++++++++++++++++++++++++ Tree_Farm/farmtree.lua | 46 ++++++++++++++++++------------------------ 2 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 Tree_Farm/choptree.lua diff --git a/Tree_Farm/choptree.lua b/Tree_Farm/choptree.lua new file mode 100644 index 0000000..9151e7c --- /dev/null +++ b/Tree_Farm/choptree.lua @@ -0,0 +1,27 @@ +--[[Tree Chopping program by Sascha +Chops down the tree in front of turtle.]] + +if not turtle.detect() then + error('Could not find tree!') +end + +print('Chopping tree...') + +if not turtle.dig() then -- chop base of tree + error('Turtle needs a digging tool!') +end + +os.sleep(5) -- Wait until everything droppen from the tree +for j = 1, 4 do + for i = 1, 4 do + if not turtle.suck() then -- Suck up all Wood + print('Did not find something to suck') + end + turtle.turnLeft() + end + turtle.forward() +end + +for i = 1, 4 do + turtle.back() +end diff --git a/Tree_Farm/farmtree.lua b/Tree_Farm/farmtree.lua index fe9d071..57b3343 100644 --- a/Tree_Farm/farmtree.lua +++ b/Tree_Farm/farmtree.lua @@ -1,43 +1,37 @@ ---[[Tree Farming program by Al Sweigart -Plants tree then cuts it down.]] +--[[Tree Farming App by Al Sweigart +Plants tree and cuts it down.]] -os.loadAPI('hare') -- load the hare module +os.loadAPI('hare.lua') -- Load the hare module local blockExists, item local logCount = 0 --- check if choptree program exists +-- Check if choptree program exists if not fs.exists('choptree.lua') then - error('You must install choptree program first.') + error('You must install choptree app first') end while true do - -- check inventory for saplings + -- Check inventory for saplings if not hare.selectItem('minecraft:spruce_sapling') then - error('Out of spruce saplings.') + error('Out of saplings') end - + print('Planting...') - turtle.place() -- plant sapling - - -- loop until a tree has grown + turtle.place() -- plant sapling + + -- Loop until tree is grown while true do blockExists, item = turtle.inspect() - if blockExists and item['name'] == 'minecraft:spruce_sapling' then - -- "dye" is the name ID for bone meal - if not hare.selectItem('minecraft:dye') then - error('Out of bone meal.') - end - - print('Using bone meal...') - turtle.place() -- use bone meal + if item['name'] ~= 'minecraft:spruce_log' then + print('wait 5 seconds') + os.sleep(5) else - break -- tree has grown - end + break -- tree has grown + end end - hare.selectEmptySlot() - shell.run('choptree') -- run choptree + shell.run('choptree.lua') -- run choptree -- move to and face chest turtle.back() @@ -45,13 +39,13 @@ while true do turtle.turnLeft() -- put logs into chest - while hare.selectItem('minecraft:log') do - logCount = logCount + turtle.getItemCount() + while hare.selectItem('minecraft:spruce_log') do + logCount = logCount + turtle.getItemCount() print('Total logs: ' .. logCount) turtle.drop() end - -- face planting spot + --face planting sport turtle.turnLeft() turtle.turnLeft() end