Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - sap=true --enables dropping of saplings in front
 - function Refuel()
 - if turtle.getFuelLevel()~=unlimited and turtle.getFuelLevel()<=75 then --gets fuel level, if unlimited is false (you get unlimited if fuel is disabled)
 - turtle.digUp()
 - turtle.select(3) --chest placing
 - turtle.placeUp()
 - turtle.placeDown()
 - turtle.select(2)
 - turtle.dropUp()
 - turtle.select(1)
 - turtle.dropUp()
 - for i=4, 16 do --unloads everything else
 - turtle.select(i)
 - if turtle.getItemCount(i)>0 then
 - turtle.dropDown(turtle.getItemCount(i))
 - end
 - end
 - while turtle.getFuelLevel()<=150 do --refuels until it has at least 150
 - turtle.select(1)
 - turtle.suckUp()
 - turtle.dropUp(turtle.getItemCount(1)-1)
 - turtle.craft()
 - turtle.refuel(4)
 - end
 - for i=1,16 do
 - turtle.select(i)
 - if i<3 then
 - turtle.suckUp()
 - elseif i>3 then
 - turtle.suckDown()
 - end
 - end
 - for i=1,2 do
 - turtle.select(i)
 - turtle.dropUp()
 - end
 - turtle.select(2)--swaps sapling back to slot 1
 - turtle.suckUp()
 - turtle.select(1)
 - turtle.suckUp()
 - turtle.select(3)
 - turtle.digUp()
 - turtle.digDown()
 - end
 - end
 - function Climb() --allows the turtle to climb to the leaves and count along the way
 - local climb=0 --set variable
 - while turtle.detectUp()==false do --waits for a leaf block and counts until then
 - turtle.up()
 - climb=climb+1
 - if climb>=15 then --prevents the turtle going obscenely high up
 - print("climbing too high. Aborting...")
 - break
 - end
 - end
 - return(climb) --returns the height
 - end
 - function ezBreak() --makes the leafharvest code easier :)
 - turtle.dig()
 - turtle.forward()
 - turtle.digUp()
 - turtle.digDown()
 - end
 - function LeafHarvest() --a very un-clean peice of code for harvesting leaves
 - turtle.digUp()
 - turtle.up()
 - turtle.digUp()
 - turtle.up()
 - turtle.turnLeft()
 - turtle.turnLeft()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - turtle.turnLeft()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - ezBreak()
 - turtle.turnRight()
 - ezBreak()
 - end
 - function TreeHarvest() --harvests the trees (obviously)
 - turtle.select(1)
 - local climb=Climb() --climbs to leaves and stores height
 - LeafHarvest() --harvests leaves
 - turtle.turnRight()
 - ezBreak()
 - for i=0,climb do --goes back down the tree, the 0 is because of how the counting works
 - turtle.down()
 - turtle.digDown()
 - end
 - turtle.down()
 - turtle.back()
 - print("Completed.")
 - end
 - function CheckHarvest() --allows the turtle to execute the harvest function seemlessly
 - if turtle.detect() then --function only does something if it finds a tree
 - turtle.down()
 - TreeHarvest()
 - turtle.select(1) --selects sapling
 - turtle.place() --places sapling
 - turtle.up() --reassumes position
 - end
 - Refuel()
 - end
 - function Move(x) --made this to add more control to movement
 - turtle.select(2) --selects wood for comparing since leaves can be low
 - for i=1,x do --made it so i didnt have to do turtle.forward() a lot
 - if turtle.detect() and turtle.compare()==false then --digs through anything but wood (leaves)
 - turtle.dig()
 - end
 - turtle.forward()
 - end
 - end
 - turtle.forward()
 - while true do --goes through the area (i know the code is anything but clean but hey, it works)
 - Move(4)
 - CheckHarvest()
 - Move(5)
 - CheckHarvest()
 - turtle.forward()
 - turtle.turnRight()
 - Move(4)
 - CheckHarvest()
 - Move(5)
 - CheckHarvest()
 - Move(5)
 - CheckHarvest()
 - Move(1)
 - turtle.turnRight()
 - Move(4)
 - CheckHarvest()
 - Move(5)
 - CheckHarvest()
 - Move(1)
 - turtle.turnRight()
 - Move(4)
 - CheckHarvest()
 - Move(1)
 - turtle.turnRight()
 - Move(4)
 - CheckHarvest()
 - Move(1)
 - turtle.turnLeft()
 - Move(4)
 - CheckHarvest()
 - Move(1)
 - turtle.turnLeft()
 - Move(4)
 - CheckHarvest()
 - Move(1)
 - turtle.turnRight()
 - Move(4)
 - CheckHarvest() --this is the last tree (add a wait if you want to be fuel efficient)
 - Move(3)
 - for i=4,16 do --drops off items
 - turtle.select(i)
 - if turtle.getItemCount(i)>0 then
 - if turtle.compare(1) and sap then --drops saplings in front
 - turtle.drop()
 - else
 - turtle.dropDown()
 - end
 - end
 - end
 - rs.setOutput("bottom",true) --pulses for minecarts
 - sleep(.2)
 - rs.setOutput("bottom",false)
 - sleep(.2)
 - turtle.back() --reassumes loop position
 - turtle.back()
 - turtle.turnRight()
 - end
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment