Added sucking up more areas

This commit is contained in:
Sascha Martens 2020-11-06 16:05:04 +01:00
parent 8fea20a1f0
commit 8f46d22501
2 changed files with 47 additions and 26 deletions

27
Tree_Farm/choptree.lua Normal file
View File

@ -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

View File

@ -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