Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SaplingSlot = 1
- BoneSlot = 2
- WoodSlot = 3
- FlintSlot = 16
- EdgeDistance = 4
- -- SaplingSide = "right"
- -- BoneSide = "back"
- -- DropSide = "right"
- -- FlintSide = "left"
- function EnsureSaplingPlaced()
- if not turtle.detect() then
- turtle.select(SaplingSlot)
- end
- turtle.place()
- end
- function Fertilize()
- turtle.select(BoneSlot)
- turtle.place()
- end
- function CheckGrown()
- if turtle.detectUp() then
- turtle.digUp()
- end
- turtle.up()
- local detected = turtle.detect()
- turtle.down()
- return detected
- end
- function IsEmpty(slot)
- local last = turtle.getSelectedSlot()
- turtle.select(slot)
- local empty = turtle.getItemCount() <= 0
- turtle.select(last)
- end
- function EnsureHasSapling()
- local hasBonemeal = not IsEmpty(BoneSlot)
- turtle.select(SaplingSlot)
- turtle.turnRight()
- turtle.suck()
- FlushExcessSaplings(hasBonemeal)
- turtle.turnLeft()
- end
- function FlushExcessSaplings(hasBonemeal)
- for i=1,16,1 do
- turtle.select(i)
- if i ~= SaplingSlot and not (hasBonemeal and i == BoneSlot) and not IsFlintAndSteel(i) then
- turtle.drop()
- end
- end
- end
- function EnsureHasBonemeal()
- turtle.select(BoneSlot)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.suck()
- FlushExcessBonemeal()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function FlushExcessBonemeal()
- for i=1,16,1 do
- if i ~= SaplingSlot and i ~= BoneSlot and not IsFlintAndSteel(i) then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- function IsFlintAndSteel(slot)
- local data = turtle.getItemDetail(slot)
- if data == nil then
- return false
- end
- local id = data.name
- return id == "minecraft:flint_and_steel"
- end
- function HasFlintAndSteel()
- return not IsEmpty(FlintSlot) and IsFlintAndSteel(FlintSlot)
- end
- function EnsureFlintAndSteel()
- if not HasFlintAndSteel() then
- turtle.turnLeft()
- turtle.select(FlintSlot)
- turtle.suck()
- turtle.turnRight()
- end
- end
- function FellTree()
- turtle.select(WoodSlot)
- turtle.dig()
- turtle.forward()
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- os.sleep(2)
- local needsBurn = false
- local last = turtle.getSelectedSlot()
- turtle.select(FlintSlot)
- while not turtle.detectDown() do
- if needsBurn then
- turtle.placeUp()
- end
- needsBurn = turtle.detect()
- turtle.down()
- end
- turtle.select(last)
- turtle.back()
- end
- function DropProduce()
- turtle.turnRight()
- for i=1,16,1 do
- if i ~= BoneSlot and i ~= SaplingSlot and i ~= FlintSlot then
- turtle.select(i)
- turtle.drop()
- end
- end
- turtle.turnLeft()
- end
- function GoToRefillPos()
- for i=1,EdgeDistance,1 do
- turtle.back()
- end
- end
- function GoToGrowPos()
- for i=1,EdgeDistance,1 do
- turtle.forward()
- end
- end
- while true do
- print("-- Ensuring Saplings")
- EnsureHasSapling()
- print("-- Ensuring Bonemeal")
- EnsureHasBonemeal()
- print("-- Ensuring Flint and Steel")
- EnsureFlintAndSteel()
- print("-- Moving to GrowPos")
- GoToGrowPos()
- print("-- Placing Sapling")
- EnsureSaplingPlaced()
- print("-- Start Fertilize-Loop")
- while not CheckGrown() do
- Fertilize()
- end
- print("-- Felling Tree")
- FellTree()
- print("-- Moving to RefillPos")
- GoToRefillPos()
- print("-- Dropping Produce")
- print("-- Cycle done.")
- print("")
- DropProduce()
- os.sleep(1)
- end
Add Comment
Please, Sign In to add comment