Advertisement
xWAFFELx

turtle autotreefarm w/ startup

Apr 8th, 2013 (edited)
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. -- Setup at http://imgur.com/a/dTqGO
  2. --once setup this tree farm will refuel itself
  3. --and reorient itself on startup without need of interaction.
  4. --based off of itsmartin's treefarm program http://youtu.be/nJYxL_sg96U
  5.  
  6.  
  7. function goHome()
  8.     turtle.select(13)
  9.     if not turtle.compareDown() then
  10.         turtle.select(14)
  11.             while not turtle.compareUp() do
  12.                 turtle.digUp()
  13.                 turtle.up()
  14.             end
  15.             while not turtle.detectDown() do
  16.                 turtle.down()
  17.             end
  18.             fuel()
  19.             moveFarmDeposit()
  20.         else
  21.            
  22.     end
  23. end
  24.  
  25. function fuel()
  26.     while turtle.getFuelLevel() <= 30 do
  27.         if turtle.getItemCount(1) == 0 then
  28.             print("Help, I'm out of fuel")
  29.             turtle.turnLeft()
  30.             turtle.turnLeft()
  31.             turtle.turnLeft()
  32.             turtle.turnLeft()
  33.             os.sleep(.5)
  34.             else
  35.             turtle.select(1)
  36.             turtle.refuel(1)
  37.             end
  38.     end
  39. end
  40.  
  41. function plantSapling()
  42.     turtle.select(16)
  43.     turtle.place()
  44. end
  45.  
  46. function waitForSaplings()
  47.     turtle.select(16)
  48.     while turtle.getItemCount(16) < 2 do
  49.         os.sleep(.5)
  50.         turtle.suckDown()
  51.     end
  52. end
  53.  
  54. function waitForTree()
  55.     turtle.select(15)
  56.     while not turtle.compare() do
  57.         os.sleep(.5)
  58.     end
  59. end
  60.  
  61. function cutTree()
  62.     turtle.select(1)
  63.     turtle.dig()
  64.     turtle.forward()
  65.     os.sleep(.5)
  66.     local count = 1
  67.     while turtle.compareUp() do
  68.         turtle.digUp()
  69.         turtle.up()
  70.         count = count + 1
  71.     end
  72.     for i=1,count do
  73.         turtle.down()
  74.     end
  75. end
  76.  
  77. function moveFarmDeposit()
  78.     for x=1,12 do
  79.         turtle.select(x)
  80.         turtle.drop()
  81.         end
  82.     turtle.back()
  83. end
  84.  
  85. goHome()
  86.  
  87. if turtle.getItemCount(13) == 0 or turtle.getItemCount(14) == 0 or turtle.getItemCount(15) == 0 then
  88. print("place 1 wood in slot 1")
  89. print("place 1 chest in slot 13")
  90. print("place 1 cobblestone in slot 14")
  91. print("place 1 piece of wood from the tree you're growing in slot 15")
  92. print("place your saplings in slot 16")
  93. return
  94. end
  95.  
  96. while true do
  97.     waitForSaplings()
  98.     plantSapling()
  99.     waitForTree()
  100.     cutTree()
  101.     fuel()
  102.     moveFarmDeposit()
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement