Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wide = 7
- local long = 9
- local sapling = "minecraft:oak_sapling"
- local log = "minecraft:oak_log"
- --function
- local function checkF()
- if turtle.getFuelLevel() == 0 then
- turtle.select(16)
- turtle.refuel(1)
- end
- end
- local function placeSapling()
- local b, data = turtle.inspectDown()
- if b == false then
- for i = 1, 15, 1 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- if turtle.getItemDetail().name == sapling then
- turtle.placeDown()
- return
- elseif i == 15 then
- io.write("No More Sapling In Inventory \n")
- end
- else
- io.write("No More Sapling at this slot \n")
- end
- end
- end
- end
- local function checkSapling()
- local b, data = turtle.inspectDown()
- if b and data.name == log then
- return true
- else
- return false
- end
- end
- local function chopTree()
- turtle.dig()
- checkF()
- turtle.digDown()
- turtle.down()
- checkF()
- turtle.up()
- checkF()
- placeSapling()
- while turtle.detectUp() do
- local a, b = turtle.inspectUp()
- if a == true and (b.name == log or b.name == "oak_leaves")then
- turtle.digUp()
- checkF()
- turtle.up()
- else
- break
- end
- end
- while turtle.detectDown() == false do
- checkF()
- turtle.down()
- local c, d = turtle.inspectDown()
- --in case the next tree grows, which blocked the path it went up
- if c == true and d.name == "minecraft:dirt" then
- checkF()
- if turtle.up() == false then
- turtle.digUp()
- turtle.up()
- end
- break
- end
- end
- end
- local function moveAround()
- checkF()
- if turtle.detect() then
- turtle.dig()
- turtle.forward()
- placeSapling()
- turtle.suckDown()
- else
- turtle.forward()
- placeSapling()
- turtle.suckDown()
- end
- end
- local function init()
- for i = 1, long, 1 do
- for j = 1, wide, 1 do
- moveAround()
- if checkSapling() then
- chopTree()
- placeSapling()
- end
- placeSapling()
- end
- if i % 2 == 1 then
- turtle.turnRight()
- moveAround()
- if checkSapling() then
- chopTree()
- end
- turtle.turnRight()
- placeSapling()
- elseif i % 2 == 0 then
- turtle.turnLeft()
- moveAround()
- if checkSapling() then
- chopTree()
- end
- turtle.turnLeft()
- placeSapling()
- end
- end
- end
- local function backToStart()
- if long % 2 == 1 then
- for i = 1,wide, 1 do
- moveAround()
- end
- turtle.turnRight()
- for i = 1, long, 1 do
- moveAround()
- end
- turtle.turnRight()
- end
- if long % 2 == 0 then
- turtle.turnLeft()
- for i = 1, wide, 1 do
- moveAround()
- end
- turtle.turnRight()
- end
- end
- local function dropoff()
- for i = 2, 15, 1 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- local function getFuel()
- turtle.select(16)
- if 64-turtle.getItemCount() <= 64 then
- turtle.select(16)
- turtle.suckUp(64-turtle.getItemCount())
- end
- end
- local function getSapling()
- turtle.select(1)
- if turtle.getItemDetail() == nil then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.suck()
- turtle.turnLeft()
- turtle.turnLeft()
- elseif (turtle.getItemDetail().name == sapling) == false then
- turtle.dropDown()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.suck()
- turtle.turnLeft()
- turtle.turnLeft()
- elseif turtle.getItemDetail().name == sapling then
- local c = turtle.getItemCount()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.suck(64 - c)
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- --main
- getSapling()
- getFuel()
- init()
- backToStart()
- getFuel()
- getSapling()
- while true do
- sleep(60)
- for i = 1, long, 1 do
- for j = 1, wide, 1 do
- moveAround()
- if checkSapling() then
- chopTree()
- placeSapling()
- end
- end
- if i % 2 == 1 then
- turtle.turnRight()
- moveAround()
- if checkSapling() then
- chopTree()
- placeSapling()
- end
- turtle.turnRight()
- elseif i % 2 == 0 then
- turtle.turnLeft()
- moveAround()
- if checkSapling() then
- chopTree()
- placeSapling()
- end
- turtle.turnLeft()
- end
- end
- backToStart()
- dropoff()
- getFuel()
- getSapling()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement