Advertisement
gustav9797

cc tree chopper

Aug 10th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. p = peripheral.wrap("right")
  2.  
  3. function refuel()
  4. if turtle.getFuelLevel() <= 20 then
  5. p.speak("Refilling fuel.")
  6. sleep(2)
  7. turtle.select(1)
  8. turtle.refuel(turtle.getItemCount(1) - 1)
  9. end
  10. end
  11.  
  12. function checkItems()
  13. if turtle.getItemCount(2) == 0 then
  14. p.speak("Please place a log in slot 2 to help me identify the tree. I am very blind.")
  15. sleep(5)
  16. end
  17. if turtle.getItemCount(3) == 0 then
  18.  
  19. end
  20. end
  21.  
  22. function hasLogInfront()
  23. turtle.select(2)
  24. if turtle.compare() then
  25. return true
  26. end
  27. end
  28.  
  29. function takeDownTree()
  30. turtle.select(2)
  31. while turtle.compare() do
  32. turtle.select(1)
  33. turtle.dig()
  34. turtle.select(2)
  35. turtle.digUp()
  36. turtle.up()
  37. end
  38. while not turtle.detectDown() do
  39. turtle.down()
  40. end
  41. end
  42.  
  43. function placeSapling()
  44. if turtle.getItemCount(3) > 1 then
  45. turtle.select(3)
  46. turtle.place()
  47. end
  48. end
  49.  
  50. function bonemeal()
  51. if turtle.getItemCount(4) > 1 then
  52. turtle.select(4)
  53. turtle.place()
  54. end
  55. end
  56.  
  57. function suckItems()
  58. turtle.select(1)
  59. turtle.suckUp()
  60. turtle.suckDown()
  61. turtle.suck()
  62. end
  63.  
  64. while true do
  65. checkItems()
  66. refuel()
  67. if hasLogInfront() then
  68. takeDownTree()
  69. end
  70. placeSapling()
  71. bonemeal()
  72. suckItems()
  73. sleep(1)
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement