Advertisement
Guest User

farmtrees004

a guest
Jun 16th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. -- farmtrees004
  2.  
  3. os.loadAPI('hare')
  4. os.loadAPI('farmmoves')
  5.  
  6. local blockExists, item
  7. local logCount = 0
  8.  
  9. -- check if treechopper exists
  10. if not fs.exists('treechopper') then
  11.     error('Install treechopper.')
  12. end
  13.  
  14. while true do
  15.     -- check inventory for saplings
  16.     if not hare.selectItem('minecraft:sapling') then
  17.         error('Out of saplings.')
  18.     end
  19.  
  20.     -- plant plot 1
  21.     print('Planting...')
  22.     turtle.place() -- plant sapling
  23.     farmmoves.moveOn()
  24.  
  25.     if not hare.selectItem('minecraft:sapling') then
  26.         error('Out of saplings.')
  27.     end
  28.  
  29.     -- plant plot 2
  30.     print('Planting...')
  31.     turtle.place() -- plant sapling
  32.     farmmoves.moveOn()
  33.  
  34.     if not hare.selectItem('minecraft:sapling') then
  35.         error('Out of saplings.')
  36.     end
  37.  
  38.     -- plant plot 3
  39.     print('Planting...')
  40.     turtle.place() -- plant sapling
  41.     farmmoves.returnHome()
  42.  
  43.  
  44.     -- loop until a tree has grown
  45.     while true do
  46.         blockExists, item = turtle.inspect()
  47.         if blockExists and item['name'] == 'minecraft:sapling' then
  48.             -- move to plot 2
  49.             farmmoves.moveOn()
  50.                 if blockExists and item['name'] == 'minecraft:sapling' then
  51.                     -- move to plot 3
  52.                     farmmoves.moveOn()
  53.                         if blockExists and item['name'] == 'minecraft:sapling' then
  54.                             -- return home
  55.                             farmmoves.returnHome()
  56.                         else
  57.                             -- plot 3 has a tree
  58.                             hare.selectEmptySlot()
  59.                             shell.run('treechopper') -- run treechopper
  60.  
  61.                             -- move to and face chest
  62.                             turtle.back()
  63.                             turtle.turnLeft()
  64.                             turtle.turnLeft()
  65.  
  66.                             -- put logs into chest
  67.                             while hare.selectItem('minecraft:log') do
  68.                                 logCount = turtle.getItemCount()
  69.                                 print('Total logs: ' .. logCount)
  70.                                 turtle.drop()
  71.                             end
  72.  
  73.                             -- face planting spot
  74.                             turtle.turnLeft()
  75.                             turtle.turnLeft()
  76.                             break
  77.                         end
  78.                 else
  79.                     -- plot 2 has a tree
  80.                     hare.selectEmptySlot()
  81.                     shell.run('treechopper') -- run treechopper
  82.  
  83.                     -- move to and face chest
  84.                     turtle.back()
  85.                     turtle.turnLeft()
  86.                     turtle.turnLeft()
  87.  
  88.                     -- put logs into chest
  89.                     while hare.selectItem('minecraft:log') do
  90.                         logCount = turtle.getItemCount()
  91.                         print('Total logs: ' .. logCount)
  92.                         turtle.drop()
  93.                     end
  94.  
  95.                     -- face planting spot
  96.                     turtle.turnLeft()
  97.                     turtle.turnLeft()
  98.                     break
  99.                 end
  100.         else
  101.             -- plot 1 has a tree
  102.             hare.selectEmptySlot()
  103.             shell.run('treechopper') -- run treechopper
  104.  
  105.             -- move to and face chest
  106.             turtle.back()
  107.             turtle.turnLeft()
  108.             turtle.turnLeft()
  109.  
  110.             -- put logs into chest
  111.             while hare.selectItem('minecraft:log') do
  112.                 logCount = turtle.getItemCount()
  113.                 print('Total logs: ' .. logCount)
  114.                 turtle.drop()
  115.             end
  116.  
  117.             -- face planting spot
  118.             turtle.turnLeft()
  119.             turtle.turnLeft()
  120.             break
  121.         end
  122.     end
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement