Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --program that has a turtle check for trees over an 8x8 square of saplings. It takes wood back to a dump chest when full and picks up fuel when needed. it needs saplings in slot 16 to replant and wood in 15 to compare. Fuel goes in slot 13.
- --chops down a tree when the turtle is positioned 1 block above the ground to clear the saplings.
- function chopTree()
- if turtle.detect() == true then
- local h = 0
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- turtle.up()
- turtle.select(16)
- turtle.placeDown()
- while turtle.compare(15) == true do
- turtle.digUp()
- h = h + 1
- end
- while h > 0 do
- turtle.down()
- end
- end
- end
- function patrolLine()
- local i = 0
- while i < 9 do
- chopTree()
- turtle.forward()
- i = i + 1
- end
- end
- function patrolAll()
- local i = 0
- while i < 4 do
- patrolLine()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- patrolLine()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- i = i + 1
- end
- i = 0
- turtle.forward()
- turtle.turnRight()
- while i < 8 do
- turtle.forward()
- i = i + 1
- end
- end
- --dumps logs then refuels from a chest above it if needed
- function dumpLogs()
- local i = 0
- while i <= 13 do
- turtle.select(i)
- turtle.drop()
- i = i + 1
- end
- turtle.up()
- if turtle.getFuelLevel() > 200 then
- turtle.select(13)
- turtle.suck(64)
- turtle.refuel()
- end
- turtle.down()
- turtle.turnRight()
- end
- function getFuel()
- turtle.select(13)
- turtle.refuel()
- end
- --main
- getFuel()
- while turtle.getFuelLevel() >=50 do
- patrolAll()
- dumpLogs()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement