deltreey

treefarm/single

Feb 8th, 2015
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. os.loadAPI('/fuel')
  2.  
  3. function refreshInventory()
  4. turtle.down()
  5. turtle.down()
  6. local current = 3
  7. while (current < 16) do
  8. turtle.select(current)
  9. turtle.dropDown()
  10. current = current + 1
  11. end
  12. turtle.select(1)
  13. turtle.suckDown(1) --Get new sapling
  14. turtle.up()
  15. turtle.up()
  16. end
  17.  
  18. function isTree()
  19. turtle.select(2)
  20. return turtle.compare()
  21. end
  22.  
  23. function chopTree()
  24. local dist = 0
  25. while (turtle.detect() and dist < 15) do
  26. turtle.dig()
  27. if (turtle.detectUp()) then
  28. turtle.digUp()
  29. end
  30. turtle.up()
  31. dist = dist + 1
  32. end
  33. while (dist > 0) do
  34. dist = dist - 1
  35. turtle.down()
  36. end
  37. end
  38.  
  39. while (true) do
  40. if (turtle.getFuelLevel() < 100) then
  41. if (fuel.canRefuel()) then
  42. fuel.fuelUp()
  43. else
  44. print('Cannot refuel')
  45. break
  46. end
  47. end
  48. if (isTree()) then
  49. chopTree()
  50. refreshInventory()
  51. turtle.place()
  52. end
  53. sleep(30)
  54. end
Advertisement
Add Comment
Please, Sign In to add comment