Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isSaplingInSlot(slot)
- sapling_list = {"minecraft:birch_sapling", "minecraft:oak_sapling", "minecraft:spruce_sapling", "minecraft:jungle_sapling", "minecraft:acacia_sapling", "minecraft:dark_oak_sapling"}
- if (slot == nil) then
- slot = turtle.getSelectedSlot()
- end
- item = turtle.getItemDetail(slot)
- if succes then
- for i=1, #sapling_list do
- if (item.tags == sapling_list[i]) then
- return true
- end
- end
- else
- -- nothing found
- return false
- end
- end
- -- is sapling
- function isSapling()
- succes, item = turtle.inspect()
- if succes and (item.tags == item.tags["minecraft:saplings"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isSaplingUp()
- succes, item = turtle.inspectUp()
- if succes and (item.tags == item.tags["minecraft:saplings"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isSaplingDown()
- succes, item = turtle.inspectDown()
- if succes and (item.tags == item.tags["minecraft:saplings"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- -- is tree
- function isTree()
- succes, item = turtle.inspect()
- if succes and (item.tags == item.tags["minecraft:logs"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isTreeUp()
- succes, item = turtle.inspectUp()
- if succes and (item.tags == item.tags["minecraft:logs"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isTreeDown()
- succes, item = turtle.inspectDown()
- if succes and (item.tags == item.tags["minecraft:logs"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- -- is leaves
- function isLeave()
- succes, item = turtle.inspect()
- if succes and (item.tags == item.tags["minecraft:leaves"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isLeaveUp()
- succes, item = turtle.inspectUp()
- if succes and (item.tags == item.tags["minecraft:leaves"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- function isLeaveDown()
- succes, item = turtle.inspectDown()
- if succes and (item.tags == item.tags["minecraft:leaves"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- -- checks for box to take saplings from or turns 360 and sucks in all aplings
- function getSaplings()
- slot = 0
- chest = peripheral.find("minecraft:chest")
- chest.side = peripheral.getName(chest)
- if chest ~= nil then
- if (chest.side == "left") then
- turtle.turnLeft()
- elseif (chest.side == "right") then
- turtle.turnRight()
- elseif (chest.side == "back") then
- turtle.turnRight()
- turtle.turnRight()
- end
- for i=1, chest.size do
- item = chest.getItemDetail(i)
- if (item.tags == item.tags["minecraft:saplings"]) then
- slot = i
- end
- end
- if (slot ~= 0) and (slot <= 15) then
- for p=1, 15 do
- if (chest.side == "top") then
- turtle.suckUp()
- elseif (chest.side == "bottom") then
- turtle.suckDown()
- else
- turtle.suck()
- end
- end
- for a=2, 16 do
- item = turtle.getItemDetail(a)
- if (item.tags == item.tags["minecraft:saplings"]) then
- turtle.select(a)
- turtle.transferTo(1)
- end
- end
- for a=2, 16 do
- if (chest.side == "top") then
- turtle.dropUp()
- elseif (chest.side == "bottom") then
- turtle.dropDown()
- else
- turtle.drop()
- end
- end
- end
- if (chest.side == "left") then
- turtle.turnRight()
- elseif (chest.side == "right") then
- turtle.turnLeft()
- elseif (chest.side == "back") then
- turtle.turnRight()
- turtle.turnRight()
- end
- else
- turtle.turnRight()
- turtle.suck()
- turtle.turnRight()
- turtle.suck()
- turtle.turnRight()
- turtle.suck()
- turtle.turnRight()
- turtle.suck()
- end
- end
- function getInventoryCount()
- items = 0
- for i=2, 16 do
- item = turtle.getItemDetail(i)
- if item ~= nil then
- items = items + item.count
- end
- end
- return items
- end
- -- ### LOOP ###
- while true do
- if isSaplingInSlot(1) == 0 then
- getSaplings()
- if isSapling() then
- --wait
- os.sleep(1)
- else
- turtle.select(1)
- turtle.place()
- end
- end
- if isTree() then
- turtle.dig()
- turtle.forward()
- while isTreeUp or isLeaveUp do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- while turtle.down() do
- -- nothing
- end
- turtle.back()
- end
- -- ### blablabla get item to chest or hopper below ###
- if getInventoryCount() > 900 then
- while getInventoryCount() < 32 do
- turtle.turnRight()
- turtle.turnRight()
- turtle.turnRight()
- turtle.turnRight()
- end
- print("Inventory cleared")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement