Build a new TreeFarm Skript
This commit is contained in:
parent
8f46d22501
commit
3ae694a216
@ -33,3 +33,20 @@ function selectEmptySlot()
|
||||
end
|
||||
return false -- couldn't find empty space
|
||||
end
|
||||
|
||||
-- getItemFromChest(chestItem) selects
|
||||
-- something from a chest in front of the turtle
|
||||
-- and pushes it into the turtle.
|
||||
function getItemFromChest(chestItem)
|
||||
sapling = peripheral.wrap('front') -- This find the chest at the front and allow you do things to it
|
||||
selectEmptySlot()
|
||||
|
||||
for slot, item in pairs(sapling.getAllStacks()) do
|
||||
if item.id == chestItem then
|
||||
-- If the chest is on the north side of the turtle, the turtle is on the south side of the peripheral
|
||||
sapling.pushItem('south', slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@ Plants tree and cuts it down.]]
|
||||
|
||||
os.loadAPI('hare.lua') -- Load the hare module
|
||||
|
||||
local NUM_OF_TREES = 4
|
||||
local TREE_SAPLING = 'spruce'
|
||||
local blockExists, item
|
||||
local logCount = 0
|
||||
|
||||
@ -12,11 +14,37 @@ if not fs.exists('choptree.lua') then
|
||||
end
|
||||
|
||||
while true do
|
||||
-- Check inventory for saplings
|
||||
if not hare.selectItem('minecraft:spruce_sapling') then
|
||||
error('Out of saplings')
|
||||
-- First, empty the whole turtle
|
||||
for i = 1, 16 do
|
||||
turtle.select(i)
|
||||
turtle.drop()
|
||||
end
|
||||
|
||||
-- Check if turtle has enough fuel
|
||||
if turtle.getFuelLevel() < (2 * (3 * NUM_OF_TREES)) then
|
||||
hare.getItemFromChest('minecraft:' .. TREE_SAPLING .. '_log')
|
||||
turtle.craft()
|
||||
hare.selectItem('minecraft:' .. TREE_SAPLING .. 'plan')
|
||||
turtle.refuel()
|
||||
end
|
||||
|
||||
-- Take one stack of Saplings from the Chest
|
||||
if not hare.getItemFromChest('minecraft:' .. TREE_SAPLING .. '_sapling') then
|
||||
error('Out of saplingurtle.craft() -- craft stone brickss')
|
||||
end
|
||||
|
||||
-- Build a Loop, where we plant and cut trees
|
||||
for i = 1, NUM_OF_TREES do
|
||||
turtle.back()
|
||||
turtle.back()
|
||||
turtle.back()
|
||||
turtle.turnRight()
|
||||
blockExists, item = turtle.inspect()
|
||||
if blockExists and item['name'] == 'minecraft:' .. TREE_SAPLING .. 'log' then
|
||||
shell.run('choptree.lua') -- Run Choptree
|
||||
elseif block Exists and item['name'] ~= 'minecraft:' .. TREE_SAPLING .. 'sapling' then
|
||||
turtle.drop()
|
||||
|
||||
print('Planting...')
|
||||
turtle.place() -- plant sapling
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user