Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sapling_list = {"minecraft:birch_sapling", "minecraft:oak_sapling", "minecraft:spruce_sapling", "minecraft:jungle_sapling", "minecraft:acacia_sapling", "minecraft:dark_oak_sapling"}
- log_list = {"minecraft:birch_log", "minecraft:oak_log", "minecraft:spruce_log", "minecraft:jungle_log", "minecraft:acacia_log", "minecraft:dark_oak_log"}
- keep_list ={"minecraft:sticks", "alexsmobs:banana"}
- fuel = turtle.getFuelLevel()
- if fuel < 10 then
- print("need fuel!")
- end
- function isLogInSlot(slot)
- if (slot == nil) then
- slot = turtle.getSelectedSlot()
- end
- item = turtle.getItemDetail(slot)
- if item ~= nil then
- for i=1, #log_list do
- if (item.name == log_list[i]) then
- return true
- end
- end
- end
- end
- function isStickInSlot(slot)
- if (slot == nil) then
- slot = turtle.getSelectedSlot()
- end
- item = turtle.getItemDetail(slot)
- if item ~= nil then
- for i=1, #keep_list do
- if (item.name == keep_list[i]) then
- return true
- end
- end
- end
- end
- function isSaplingInSlot(slot)
- if (slot == nil) then
- slot = turtle.getSelectedSlot()
- end
- item = turtle.getItemDetail(slot)
- if item ~= nil then
- for i=1, #sapling_list do
- if (item.name == sapling_list[i]) then
- return true
- end
- end
- end
- end
- -- isSapling
- function isSapling()
- succes, item = turtle.inspect()
- if succes and (item.tags["minecraft:saplings"]) then
- return true
- else
- -- nothing found
- return false
- end
- end
- -- isTree
- function isTree(side)
- if side == nil then
- side = "front"
- succes, item = turtle.inspect()
- elseif side == "front" then
- side = "front"
- succes, item = turtle.inspect()
- elseif side == "top" then
- succes, item = turtle.inspectUp()
- end
- if succes and (item.tags["minecraft:logs"]) then
- return true, side
- else
- -- nothing found
- return false
- end
- end
- -- isLeaves
- function isLeave()
- if side == nil then
- side = "front"
- succes, item = turtle.inspect()
- elseif side == "front" then
- side = "front"
- succes, item = turtle.inspect()
- elseif side == "top" then
- succes, item = turtle.inspectUp()
- end
- if succes and (item.tags["minecraft:leaves"]) then
- return true, side
- else
- -- nothing found
- return false
- end
- end
- -- checks for box to take saplings from or turns 360 and sucks in all aplings
- function getSaplings()
- chest = peripheral.find("minecraft:chest")
- if chest ~= nil then
- turtle.select(1)
- for t=1, 16 do
- turtle.suckDown()
- end
- for slot=1,16 do
- turtle.select(slot)
- if isSaplingInSlot(slot) then
- turtle.transferTo(1,turtle.getItemCount(slot))
- else
- turtle.drop(turtle.getItemCount(slot))
- end
- end
- end
- end
- function sortInventory(fromInventory, toInventory)
- chest = peripheral.find("minecraft:chest")
- if chest ~= nil then
- turtle.select(1)
- for t=1, 16 do
- turtle.suckDown()
- end
- for slot=1,16 do
- turtle.select(slot)
- if isLogInSlot(slot) or isStickInSlot(slot) then
- turtle.drop(turtle.getItemCount(slot))
- end
- end
- 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 = 0
- -- ### LOOP ###
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print(loop)
- if isLogInSlot(1) then
- turtle.dropDown()
- end
- if isSapling() then
- --wait
- print("Sapling detected, waiting for tree")
- for p=0,10 do
- rs.setOutput("left", true)
- os.sleep(0.1)
- rs.setOutput("left", false)
- os.sleep(0.1)
- end
- else
- if isSaplingInSlot(1) then
- print("Sapling found, planting")
- turtle.place()
- else
- print("no sapling found, searching")
- turtle.turnRight()
- turtle.turnRight()
- getSaplings()
- sortInventory("bottom", "front")
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(1)
- end
- end
- if isTree() then
- turtle.dig()
- turtle.forward()
- while isTree("top") or isLeave("top") do
- turtle.dig()
- turtle.digUp()
- turtle.up()
- end
- while turtle.down() do
- -- nothing
- end
- turtle.back()
- turtle.turnRight()
- turtle.turnRight()
- turtle.suck()
- turtle.turnLeft()
- turtle.turnLeft()
- os.sleep(10)
- end
- loop = loop + 1
- if loop >= 100 then
- loop = 1
- end
- os.sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement