Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local saplings = {"minecraft:oak_sapling", "minecraft:spruce_sapling", "minecraft:birch_sapling", "minecraft:jungle_sapling"}
- local logs = {"minecraft:oak_log", "minecraft:spruce_log", "minecraft:brich_log", "minecraft:jungle_log"}
- local turningRight = true
- function fell()
- success, data = turtle.inspect()
- successDown = turtle.inspectDown()
- breaker = false
- if success then
- -- Log
- while inTable(data.name, logs) do
- -- os.sleep(0.5)
- turtle.dig()
- turtle.digUp()
- turtle.up()
- success, data = turtle.inspect()
- successDown = turtle.inspectDown()
- end
- -- Reset
- while not (success and successDown) do
- turtle.down()
- successDown = turtle.inspectDown()
- if successDown then replant() end
- success, data = turtle.inspect()
- end
- end
- end
- function replant()
- for i = 1, 16 do
- turtle.select(i)
- iData = turtle.getItemDetail()
- if not (iData == nil) then
- if inTable(iData.name, saplings) then
- turtle.place()
- break
- end
- end
- end
- end
- function refuel()
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- local halfStack = math.ceil(turtle.getItemCount(i)/2)
- turtle.refuel(halfStack)
- end
- end
- end
- function inTable(obj, table)
- for i in pairs(table) do
- if obj == table[i] then return true end
- end
- return false
- end
- function shiftRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- function shiftLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function move()
- success, data = turtle.inspect()
- if not (inTable(data.name, saplings) or inTable(data.name, logs)) then
- turningRight = not turningRight
- end
- if turningRight then shiftRight()
- else shiftLeft()
- end
- end
- while true do
- if turtle.getFuelLevel() < 11 then
- refuel()
- end
- move()
- -- os.sleep(0.5)
- fell()
- end
Add Comment
Please, Sign In to add comment