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 --[[Tree Farming App by Al Sweigart
Plants tree then cuts it down.]] 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 blockExists, item
local logCount = 0 local logCount = 0
-- check if choptree program exists -- Check if choptree program exists
if not fs.exists('choptree.lua') then if not fs.exists('choptree.lua') then
error('You must install choptree program first.') error('You must install choptree app first')
end end
while true do while true do
-- check inventory for saplings -- Check inventory for saplings
if not hare.selectItem('minecraft:spruce_sapling') then if not hare.selectItem('minecraft:spruce_sapling') then
error('Out of spruce saplings.') error('Out of saplings')
end end
print('Planting...') print('Planting...')
turtle.place() -- plant sapling turtle.place() -- plant sapling
-- loop until a tree has grown -- Loop until tree is grown
while true do while true do
blockExists, item = turtle.inspect() blockExists, item = turtle.inspect()
if blockExists and item['name'] == 'minecraft:spruce_sapling' then if item['name'] ~= 'minecraft:spruce_log' then
-- "dye" is the name ID for bone meal print('wait 5 seconds')
if not hare.selectItem('minecraft:dye') then os.sleep(5)
error('Out of bone meal.')
end
print('Using bone meal...')
turtle.place() -- use bone meal
else else
break -- tree has grown break -- tree has grown
end end
end end
hare.selectEmptySlot() hare.selectEmptySlot()
shell.run('choptree') -- run choptree shell.run('choptree.lua') -- run choptree
-- move to and face chest -- move to and face chest
turtle.back() turtle.back()
@ -45,13 +39,13 @@ while true do
turtle.turnLeft() turtle.turnLeft()
-- put logs into chest -- put logs into chest
while hare.selectItem('minecraft:log') do while hare.selectItem('minecraft:spruce_log') do
logCount = logCount + turtle.getItemCount() logCount = logCount + turtle.getItemCount()
print('Total logs: ' .. logCount) print('Total logs: ' .. logCount)
turtle.drop() turtle.drop()
end end
-- face planting spot --face planting sport
turtle.turnLeft() turtle.turnLeft()
turtle.turnLeft() turtle.turnLeft()
end end