Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Setup at http://imgur.com/a/dTqGO
- --once setup this tree farm will refuel itself
- --and reorient itself on startup without need of interaction.
- --based off of itsmartin's treefarm program http://youtu.be/nJYxL_sg96U
- function goHome()
- turtle.select(13)
- if not turtle.compareDown() then
- turtle.select(14)
- while not turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- turtle.down()
- end
- fuel()
- moveFarmDeposit()
- else
- end
- end
- function fuel()
- while turtle.getFuelLevel() <= 30 do
- if turtle.getItemCount(1) == 0 then
- print("Help, I'm out of fuel")
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.turnLeft()
- os.sleep(.5)
- else
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- end
- function plantSapling()
- turtle.select(16)
- turtle.place()
- end
- function waitForSaplings()
- turtle.select(16)
- while turtle.getItemCount(16) < 2 do
- os.sleep(.5)
- turtle.suckDown()
- end
- end
- function waitForTree()
- turtle.select(15)
- while not turtle.compare() do
- os.sleep(.5)
- end
- end
- function cutTree()
- turtle.select(1)
- turtle.dig()
- turtle.forward()
- os.sleep(.5)
- local count = 1
- while turtle.compareUp() do
- turtle.digUp()
- turtle.up()
- count = count + 1
- end
- for i=1,count do
- turtle.down()
- end
- end
- function moveFarmDeposit()
- for x=1,12 do
- turtle.select(x)
- turtle.drop()
- end
- turtle.back()
- end
- goHome()
- if turtle.getItemCount(13) == 0 or turtle.getItemCount(14) == 0 or turtle.getItemCount(15) == 0 then
- print("place 1 wood in slot 1")
- print("place 1 chest in slot 13")
- print("place 1 cobblestone in slot 14")
- print("place 1 piece of wood from the tree you're growing in slot 15")
- print("place your saplings in slot 16")
- return
- end
- while true do
- waitForSaplings()
- plantSapling()
- waitForTree()
- cutTree()
- fuel()
- moveFarmDeposit()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement