Added new scripts and sorted things

This commit is contained in:
TheLux83
2020-11-06 12:00:34 +01:00
parent d35c9517f9
commit 8fea20a1f0
4 changed files with 187 additions and 0 deletions

57
Tree_Farm/farmtree.lua Normal file
View File

@ -0,0 +1,57 @@
--[[Tree Farming program by Al Sweigart
Plants tree then cuts it down.]]
os.loadAPI('hare') -- load the hare module
local blockExists, item
local logCount = 0
-- check if choptree program exists
if not fs.exists('choptree.lua') then
error('You must install choptree program first.')
end
while true do
-- check inventory for saplings
if not hare.selectItem('minecraft:spruce_sapling') then
error('Out of spruce saplings.')
end
print('Planting...')
turtle.place() -- plant sapling
-- loop until a tree has 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
else
break -- tree has grown
end
end
hare.selectEmptySlot()
shell.run('choptree') -- run choptree
-- move to and face chest
turtle.back()
turtle.turnLeft()
turtle.turnLeft()
-- put logs into chest
while hare.selectItem('minecraft:log') do
logCount = logCount + turtle.getItemCount()
print('Total logs: ' .. logCount)
turtle.drop()
end
-- face planting spot
turtle.turnLeft()
turtle.turnLeft()
end