Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----- https://drive.google.com/drive/folders/1kjauE0XBuLGPOfnKRHc-a4aVUoU9wZYT
- ----crafty turtle! chest in slot 16, saplings in slot 1
- moves = 0
- treemined = false
- local chestName = "minecraft:barrel"
- craftTable = peripheral.wrap("right")
- function movesUp()
- repeat
- turtle.digUp()
- until turtle.up()
- moves = moves + 1
- end
- function movesDown()
- if turtle.down() then
- moves = moves - 1
- else
- turtle.digDown()
- end
- end
- function inspect()
- local success, data = turtle.inspect()
- if data.name == "minecraft:spruce_log" then
- holz = true
- else
- holz = false
- end
- if data.name == "minecraft:spruce_sapling" then
- sapling = true
- else
- sapling = false
- end
- --print(data.name)
- end
- function inspectDown()
- local success, data = turtle.inspectDown()
- if data.name == "minecraft:spruce_sapling" then
- sapling = true
- else
- sapling = false
- end
- if data.name == "minecraft:dirt" or data.name == "minecraft:podzol" then
- bottom = true
- else
- bottom = false
- end
- --print(data.name)
- end
- function goUp()
- repeat
- inspect()
- turtle.dig()
- if moves == 0 then
- turtle.select(1)
- turtle.place()
- end
- if moves == 1 then
- turtle.select(1)
- turtle.placeDown()
- end
- movesUp()
- until holz == false
- end
- function goDown()
- repeat
- turtle.dig()
- turtle.digDown()
- movesDown()
- inspectDown()
- until moves == 1 or bottom == true
- if bottom == true then
- turtle.up()
- moves = 1
- end
- end
- function changepos()
- turtle.digDown()
- if moves == 1 then
- turtle.select(1)
- turtle.placeDown()
- end
- repeat turtle.dig() until turtle.forward()
- turtle.digUp()
- if dir == "l" then
- turtle.turnLeft()
- elseif dir == "r" then
- turtle.turnRight()
- end
- turtle.digDown()
- if moves == 1 then
- turtle.select(1)
- turtle.placeDown()
- end
- repeat turtle.dig() until turtle.forward()
- if dir == "l" then
- turtle.turnLeft()
- elseif dir == "r" then
- turtle.turnRight()
- end
- turtle.digUp()
- if moves == 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- repeat turtle.dig() until turtle.forward()
- repeat turtle.digDown() until turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- function checksaplings()
- if turtle.getItemCount(1) > 0 then
- data = turtle.getItemDetail(1)
- if data.name ~= "minecraft:spruce_sapling" then
- repeat
- print("No Saplings, something went wrong.")
- sleep(5)
- data = turtle.getItemDetail(1)
- until data.name == "minecraft:spruce_sapling"
- end
- else
- repeat
- print("No Saplings, something went wrong.")
- sleep(5)
- until turtle.getItemCount(1) > 0
- end
- end
- function minetree()
- checksaplings()
- getinPos()
- goUp()
- changepos()
- goDown()
- changepos()
- moves = 0
- treemined = true
- end
- function getinPos()
- repeat turtle.dig() until turtle.forward()
- end
- function checktrees()
- repeat turtle.dig() until turtle.forward()
- ---vor links
- dir = "r"
- turtle.turnLeft()
- inspect()
- if holz == true then
- minetree()
- end
- --vor rechts
- dir = "l"
- turtle.turnRight()
- turtle.turnRight()
- inspect()
- if holz == true then
- minetree()
- end
- --transition
- turtle.turnRight()
- repeat turtle.dig() until turtle.forward()
- repeat turtle.dig() until turtle.forward()
- ----
- ---back links
- dir = "r"
- turtle.turnLeft()
- inspect()
- if holz == true then
- minetree()
- end
- --back rechts
- dir = "l"
- turtle.turnRight()
- turtle.turnRight()
- inspect()
- if holz == true then
- minetree()
- end
- --
- turtle.turnRight()
- turtle.select(1)
- saplings = turtle.getItemSpace(1)
- turtle.suckDown(saplings)
- repeat turtle.dig() until turtle.forward()
- end
- function turtleFind(itemName)
- for i=1, 16 do
- local itemz = turtle.getItemDetail(i)
- if itemz then
- if itemz.name == itemName then
- turtle.select(i)
- return i
- end
- end
- end
- end
- function dropitems()
- for i=2,15 do
- if turtle.getItemCount(i) > 0 then
- data = turtle.getItemDetail(i)
- turtle.select(i)
- if data.name == "minecraft:spruce_log" then
- if turtle.dropDown() == false then
- repeat
- sleep(2)
- print("Nowhere to put item")
- until turtle.dropDown()
- end
- else
- turtle.dropUp()
- end
- end
- end
- end
- function placechest()
- turtleFind(chestName)
- repeat
- turtle.dig()
- until turtle.place()
- end
- function retrievechest()
- turtle.select(1)
- repeat until turtle.suck() == false
- turtle.select(16)
- turtle.dig()
- turtle.select(1)
- end
- function checkname()
- if turtle.getItemCount(slot) > 0 then
- if data.name == "minecraft:spruce_log" then
- return true
- end
- end
- end
- function craft()
- turtle.select(16)
- while craftTable.craft() do
- stacksize = turtle.getItemCount(16)
- turtle.refuel(stacksize)
- end
- end
- function findwood()
- slot = 0
- repeat
- slot = slot + 1
- data = turtle.getItemDetail(slot)
- if turtle.getItemCount(slot) > 0 then
- if data.name ~= "minecraft:spruce_log" then
- turtle.select(slot)
- turtle.drop()
- end
- end
- until slot == 15 or checkname() == true
- if slot ~= 15 then
- slot = slot + 1
- for i =slot, 15 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- shell.run("refuel".." ".."all")
- end
- function refuel()
- placechest()
- findwood()
- retrievechest()
- end
- ---do all the things
- function allthethings()
- while true do
- checktrees()
- if turtle.getFuelLevel() < 6000 then
- if treemined == true then
- refuel()
- end
- end
- dropitems()
- sleep(15)
- treemined = false
- end
- end
- allthethings()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement