DrFair

Tree farm

Feb 18th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. z = 0
  2.  
  3. function moveUp()
  4. if turtle.up() then
  5. z = z + 1
  6. return true
  7. end
  8. end
  9.  
  10. function moveDown()
  11. if turtle.down() then
  12. z = z - 1
  13. return true
  14. end
  15. end
  16.  
  17. function mineUp()
  18. turtle.dig()
  19. turtle.digUp()
  20. moveUp()
  21. end
  22.  
  23. function dropOff()
  24. print("Dropping off items..")
  25. turtle.turnRight()
  26. turtle.turnRight()
  27. turtle.select(1)
  28. turtle.drop(turtle.getItemCount(1)-1)
  29. turtle.turnRight()
  30. turtle.turnRight()
  31. end
  32.  
  33. function chopTree()
  34. print("Chopping tree.")
  35. turtle.select(1)
  36. while turtle.compare() do
  37. mineUp()
  38. end
  39. for i=1,z do
  40. moveDown()
  41. end
  42. end
  43.  
  44. function waitGrow()
  45. print("Waiting for grow..")
  46. while not turtle.compare() do
  47. os.sleep(1)
  48. end
  49. print("Tree grew!")
  50. return true
  51. end
  52.  
  53. function placeSapling()
  54. turtle.select(2)
  55. turtle.place()
  56. turtle.select(1)
  57. end
  58.  
  59. function farm()
  60. placeSapling()
  61. waitGrow()
  62. chopTree()
  63. dropOff()
  64. os.sleep(1)
  65. end
  66.  
  67. while true do
  68. farm()
  69. end
Advertisement
Add Comment
Please, Sign In to add comment