Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SAPLING = "minecraft:sapling"--always be slot 2
- LOG = "minecraft:log"
- FUEL = "minecraft:coal"
- --charcoal always slot 1
- WIDTH = 2
- LENGTH = 11
- DELAY = 60 -- seconds
- move = 3
- function dropLoot()
- local data = turtle.getItemDetail(1)
- if data and data.name ~= FUEL then
- turtle.dropDown(1)
- end
- for i=3,16 do
- turtle.dropDown(i)
- end
- end
- function refuel()
- local data = turtle.getItemDetail(1)
- if data and data.name == FUEL then
- turtle.select(1)
- turtle.suckDown(64-data.count)
- turtle.refuel()
- else
- turtle.select(1)
- turtle.suckDown(64)
- turtle.refuel()
- end
- end
- function estimateFuelNeed()
- return WIDTH * LENGTH * 5 * 5
- end
- function fell()
- refuel()
- if turtle.getFuelLevel() < estimateFuelNeed() then
- return false
- end
- for w=1,WIDTH do
- x = LENGTH
- if w ~= 1 then
- x = x - 1
- end
- for i=1,x do
- for j=1,move do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- local s,d = turtle.inspectDown()
- local saplinginfo = turtle.getItemDetail(2)
- if s then
- if d.name == SAPLING then
- --keep moving, it aint done yet
- elseif d.name == LOG then
- --break all the logs and replant
- turtle.digDown()
- local count = 0
- local s_, d_ = turtle.inspectUp()
- while s_ and d_.name == LOG do
- turtle.digUp()
- turtle.up()
- count = count + 1
- s_, d_ = turtle.inspectUp()
- end
- for j=1,count do
- turtle.down()
- end
- turtle.select(2)
- turtle.placeDown()
- end
- os.sleep(3)
- turtle.suck()
- else
- --there should be a sapling or a log here..
- --replanting anyway
- turtle.select(2)
- turtle.placeDown()
- end
- if i ~= LENGTH then
- move = 5
- elseif w == WIDTH then
- for j=1, 3 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnRight()
- for j=1, 3 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- dropLoot()
- for j=1, 2 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnRight()
- else
- move = 5
- turtle.turnRight()
- for j=1, 5 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnRight()
- end
- end
- end
- return true
- end
- while true do
- if not fell() then
- print('couldnt start, not enough fuel. need at least ' .. estimateFuelNeed())
- end
- os.sleep(DELAY)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement