Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = ...
- local size = a or 10
- local timer = 0
- local blocks = {
- 'log',
- 'blockRubWood'
- }
- local saplings = {
- 'sapling',
- 'chest',
- 'torch'
- }
- function checkSapling(s)
- s = s:lower()
- local a = false
- for i, p in ipairs(saplings) do
- a = a or string.find(s, p:lower())
- end
- return a
- end
- function digForward()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function match(s)
- s = s:lower()
- local a = false
- for i, p in ipairs(blocks) do
- a = a or string.find(s, p:lower())
- end
- return a
- end
- function harvestTree()
- local height = 0
- turtle.digDown()
- while turtle.detectUp() do
- turtle.digUp()
- if turtle.up() then
- height = height + 1
- end
- end
- for i = 1, height do
- while not turtle.down() do turtle.digDown() end
- end
- end
- turtle.select(1)
- while true do
- local right = true
- for x = 1, size do
- for y = 1, size do
- turtle.suckDown()
- if ((not turtle.detectDown()) and (turtle.getItemCount(1) > 1)) then
- turtle.placeDown()
- end
- local a, data = turtle.inspectUp()
- if a and match(data.name) then
- harvestTree()
- else
- local b, data2 = turtle.inspectDown()
- if b and not checkSapling(data2.name) then
- turtle.digDown()
- end
- if a then turtle.digUp() end
- end
- digForward()
- end
- if right then
- turtle.turnRight()
- digForward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- digForward()
- turtle.turnLeft()
- end
- right = not right
- digForward()
- end
- if right then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for i = 1, size do
- digForward()
- end
- if right then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- local a, data = turtle.inspectDown()
- if a and string.find(data.name:lower(), 'chest') then
- for i = 2, 16 do
- turtle.select(i)
- turtle.dropDown(64)
- end
- end
- sleep(timer)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement