Advertisement
Guest User

farmtrees003

a guest
Jun 16th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. -- farmtrees003
  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.                             break -- plot 3 has a tree
  58.                         end
  59.                 else
  60.                     break -- plot 2 has a tree
  61.                 end
  62.         else
  63.             -- plot 1 has a tree
  64.             hare.selectEmptySlot()
  65.             shell.run('treechopper') -- run treechopper
  66.  
  67.             -- move to and face chest
  68.             turtle.back()
  69.             turtle.turnLeft()
  70.             turtle.turnLeft()
  71.  
  72.             -- put logs into chest
  73.             while hare.selectItem('minecraft:log') do
  74.                 logCount = turtle.getItemCount()
  75.                 print('Total logs: ' .. logCount)
  76.                 turtle.drop()
  77.             end
  78.  
  79.             -- face planting spot
  80.             turtle.turnLeft()
  81.             turtle.turnLeft()
  82.             break
  83.         end
  84.     end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement