Advertisement
asweigart

enderpearlfarmer

Mar 28th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. os.loadAPI('hare')
  2. hare.goto(765,61,-664)
  3. hare.faceNorth()
  4.  
  5. local tArgs = {...}
  6. if tonumber(tArgs[1]) == nil then tArgs[1] = 8 end
  7. if tonumber(tArgs[2]) == nil then tArgs[2] = 8 end
  8.  
  9.  
  10. local FORWARD_LEN = tonumber(tArgs[1])
  11. local RIGHT_LEN = tonumber(tArgs[2])
  12. local i
  13.  
  14.  
  15. local movements = hare.split(hare.getAreaCoverActions(FORWARD_LEN, RIGHT_LEN, true))
  16.  
  17. while true do
  18. for i=1,#movements do
  19. hare.doActions(movements[i], true)
  20.  
  21. local exists, block = turtle.inspectDown()
  22. if exists and (string.find(block['name'], 'chest') or string.find(block['name'], 'barrel')) then
  23. -- drop off inventory into chest
  24. print('Dropping off inventory into chest...')
  25. for i=1,16 do
  26. turtle.select(i)
  27. itemData = turtle.getItemDetail()
  28. if itemData ~= nil and itemData['name'] == 'ExtraUtilities:plant/ender_lilly' then
  29. pearlCount = pearlCount + turtle.getItemCount()
  30. turtle.dropDown(64) -- deposit into chest
  31. end
  32. end
  33. print(' ', pearlCount, ' pearls deposited.')
  34. pearlCount = 0
  35. elseif not exists then
  36. -- nothing is under the turtle, so try to plant lilly
  37. hare.selectItem('ExtraUtilities:plant/ender_lilly')
  38. turtle.placeDown()
  39. elseif block['name'] == 'ExtraUtilities:plant/ender_lilly' and block['metadata'] == 3 then
  40. -- ender pearl (and fully mature) is below, so harvest it
  41. turtle.digDown()
  42. turtle.suckDown() -- pick up any ender pearls
  43. hare.selectItem('ExtraUtilities:plant/ender_lilly')
  44. turtle.placeDown()
  45. end
  46. end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement