Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Keeps track of what side the tree is on true is right false is left
- local wSide = true
- -- Stay fueled up, uses the logs it harvests for fuel
- local function fuelTime()
- if turtle.getFuelLevel() < 200 then
- turtle.select(2)
- turtle.refuel(1)
- turtle.select(1)
- end
- end
- local function chopTime()
- -- Determines if the tree is on the left or right.
- if wSide then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- -- If there is somthing there try to harvest it.
- if turtle.detect() then
- turtle.dig()
- turtle.forward()
- -- Climbs the tree
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- -- Goes back to the ground
- while not turtle.detectDown() do
- turtle.down()
- end
- turtle.back()
- end
- -- If there is nothing there plant a sapling
- if not turtle.detect() then
- turtle.select(1)
- turtle.place()
- end
- -- Determines what direction it wants to go
- if wSide then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- -- Moves to the next tree
- local function nextRow()
- for i=1,4 do
- turtle.forward()
- end
- end
- -- Moves to the next column of trees
- local function nextColumn()
- turtle.forward()
- if wSide then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- for i=1,4 do
- turtle.forward()
- end
- if wSide then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- turtle.forward()
- -- Lets it know what side of the trees it is on
- wSide = not wSide
- end
- -- Returns back to the starting point
- local function homeTime()
- for i=1,26 do
- turtle.back()
- end
- turtle.turnLeft()
- for i=1,24 do
- turtle.forward()
- end
- turtle.turnRight()
- wSide = true
- end
- -- Drops what it picked up into a water flow below
- local function dropLoot()
- for i=3,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- end
- -- make it run
- while true do
- fuelTime()
- turtle.forward()
- turtle.forward()
- for i=1,7 do
- fuelTime()
- for n=1,7 do
- chopTime()
- dropLoot()
- if n < 7 then
- nextRow()
- end
- end
- if i < 7 then
- nextColumn()
- end
- end
- homeTime()
- -- Pause for 2 min while the trees regrow
- os.sleep(120)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement