Advertisement
cowslaw

Turtle Tree Farm

Apr 9th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. -- 2x2 Tree Farm By: ZakyyyHD
  2. -- Save as "Fell." Capital "F" is required.
  3. -- Protected under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported (http://creativecommons.org/licenses/by-nc-nd/3.0/)
  4. --   Sapling chest to the LEFT of starting position.
  5. --   Dump chest BEHIND starting position.
  6. --   Bonemeal chest to the RIGHT of starting position.
  7.  
  8.  
  9. -- Functions
  10.  
  11. -- Turn Around
  12. function tAr()
  13.  for t = 1, 2 do
  14.   turtle.turnRight(t)
  15.  end
  16. end
  17.  
  18. -- Fell Vertically Up
  19. function flUp()
  20.  while turtle.detectUp() == true do
  21.   cFuel()
  22.   turtle.dig()
  23.   turtle.digUp()
  24.   turtle.up()
  25.   height = height + 1
  26.  end
  27. end
  28.  
  29. -- Fell Vertically Down
  30. function flDown()
  31.  for x = 1, height do
  32.   cFuel()
  33.   turtle.digDown()
  34.   turtle.down()
  35.   turtle.dig()
  36.  end
  37. end
  38.  
  39. -- Refuel
  40. function cFuel()
  41.  if turtle.getFuelLevel() < 15 then
  42.   turtle.select(1)
  43.   turtle.refuel(2)
  44.  end
  45. end
  46.  
  47. -- Drop Items
  48. function dropI()
  49.  tAr()
  50.   for i = 4, 16 do
  51.    turtle.select(i)
  52.    turtle.drop()
  53.   end
  54.  tAr()
  55. end
  56.    
  57. -- Check Sapling
  58. function cSapling()
  59.  if turtle.getItemCount(2) < 16 then
  60.   turtle.turnLeft()
  61.   turtle.select(2)
  62.   turtle.suck()
  63.   turtle.select(1)
  64.   turtle.turnRight()
  65.  end
  66. end
  67.  
  68. -- Grow Tree
  69. function grow()
  70.  turtle.select(3)
  71.  turtle.place()
  72.  turtle.select(1)
  73. end
  74.  
  75. -- Check Bonemeal
  76. function cBonemeal()
  77.  if turtle.getItemCount(3) < 1 then
  78.   turtle.turnRight()
  79.   turtle.select(3)
  80.   turtle.suck()
  81.   turtle.select(1)
  82.   turtle.turnLeft()
  83.  end
  84. end
  85.  
  86. -- Place Saplings
  87. function replant()
  88.  turtle.select(2)
  89.  turtle.forward()
  90.  turtle.forward()
  91.  turtle.turnRight()
  92.  sleep(.5)
  93.  turtle.place()
  94.  sleep(.5)
  95.  turtle.turnLeft()
  96.  turtle.back()
  97.  sleep(.5)
  98.  turtle.place()
  99.  sleep(.5)
  100.  turtle.turnRight()
  101.  sleep(.5)
  102.  turtle.place()
  103.  sleep(.5)
  104.  turtle.turnLeft()
  105.  turtle.back()
  106.  sleep(.5)
  107.  turtle.place()
  108.  sleep(.5)
  109. end
  110.  
  111. -- Main loop
  112.  while true do
  113.   height = 0
  114.   cFuel()
  115.   cSapling()
  116.   cBonemeal()
  117.   replant()
  118.   grow()
  119.   turtle.dig()
  120.   turtle.forward()
  121.   flUp()
  122.   turtle.dig()
  123.   turtle.turnRight()
  124.   turtle.dig()
  125.   turtle.forward()
  126.   turtle.turnLeft()
  127.   turtle.dig()
  128.   flDown()
  129.   turtle.turnLeft()
  130.   turtle.forward()
  131.   turtle.turnRight()
  132.   turtle.back()
  133.   dropI()
  134.  end
  135.  
  136. shell.run("Fell")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement