Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- chtreefarmtest: slightly modified Treefarm by itsmartin (from pastebin.com/tyykzGqj)
- --
- -- Place fuel in slot 14, saplings in slot 15 and 1 dirt in slot 16.
- -- See http://youtu.be/nJYxL_sg96U for setup
- function forwardBy(n)
- for i=1,n do
- turtle.forward()
- end
- end
- function moveHomeFarm()
- forwardBy(5)
- turtle.turnLeft()
- forwardBy(5)
- turtle.turnLeft()
- end
- function plantSapling()
- turtle.select(16)
- turtle.place()
- turtle.up()
- turtle.select(15)
- turtle.place()
- end
- function waitForSaplings()
- turtle.select(15)
- while turtle.getItemCount(15) < 2 do
- os.sleep(2)
- sleep(2)
- turtle.suckDown()
- end
- end
- function waitForTree()
- local treeFoundCount = 0
- turtle.up()
- while treeFoundCount<10 do
- while treeFoundCount<10 do
- os.sleep(2)
- sleep(2)
- while not turtle.detect() do
- os.sleep(2)
- sleep(2)
- end
- treeFoundCount = treeFoundCount + 1
- end
- turtle.down()
- turtle.select(15)
- os.sleep(2)
- sleep(2)
- if turtle.compare() then
- treeFoundCount = 0
- turtle.up()
- end
- end
- turtle.select(16)
- turtle.down()
- turtle.dig()
- turtle.forward()
- end
- function cutTree()
- turtle.select(1)
- turtle.digUp()
- turtle.up()
- local count = 1
- while count<12 and turtle.compareUp() and turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- count = count + 1
- end
- for i=1,count do
- turtle.down()
- end
- end
- function moveFarmDeposit()
- turtle.turnRight()
- forwardBy(4)
- turtle.turnLeft()
- forwardBy(4)
- turtle.select(1)
- turtle.dropDown()
- turtle.turnLeft()
- forwardBy(9)
- turtle.turnLeft()
- end
- while true do
- if turtle.getFuelLevel() < 50 then
- turtle.select(14)
- turtle.refuel()
- if turtle.getFuelLevel() < 50 then
- write("Not enough fuel\n")
- return
- end
- end
- if turtle.getItemCount(16) < 1 then
- write("Dirt goes in slot 16\n")
- return
- end
- if turtle.getItemCount(15) < 2 then
- write("Multiple saplings go in slot 15\n")
- return
- end
- waitForSaplings()
- moveHomeFarm()
- plantSapling()
- waitForTree()
- cutTree()
- moveFarmDeposit()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement