Nalakava

Lumberjack

Dec 14th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. -- advanced turtle lumberjack
  2. shell.run('clear')
  3. print("Please put Dirt in Slot 1, Saplings in Slot 2, and a log in Slot 3.")
  4. print("Number of Trees To Plant?")
  5. local x = io.read()
  6. local dirt, sapling, log = 1, 2, 3
  7.  
  8. -- get into position
  9. turtle.up()
  10. turtle.turnLeft()
  11. turtle.turnLeft()
  12. turtle.back()
  13. turtle.back()
  14. turtle.back()
  15.  
  16. -- initial planting
  17. for i = 0, x do
  18. turtle.digDown()
  19. turtle.select(dirt)
  20. turtle.placeDown()
  21. turtle.back()
  22. turtle.select(sapling)
  23. turtle.place()
  24. turtle.back()
  25. turtle.back()
  26. turtle.back()
  27. end
  28. turtle.turnLeft()
  29. turtle.forward()
  30. turtle.turnRight()
  31.  
  32. --chop trees
  33. while true do
  34. -- sleep for 30 seconds
  35. os.sleep(30)
  36. -- check all trees for any that have grown
  37. for i = 0, x do
  38. turtle.forward()
  39. turtle.forward()
  40. turtle.forward()
  41. turtle.forward()
  42. turtle.turnRight()
  43. turtle.select(log)
  44. -- if the tree has grown
  45. if turtle.compare() then
  46. turtle.dig()
  47. turtle.forward()
  48. -- harvest the tree
  49. while turtle.detectUp() do
  50. turtle.digUp()
  51. turtle.up()
  52. end
  53. -- return to the ground
  54. while not turtle.detectDown() do
  55. turtle.down()
  56. end
  57. -- plant a new sapling
  58. turtle.back()
  59. turtle.select(sapling)
  60. turtle.place()
  61. end
  62. turtle.turnLeft()
  63. end
  64. -- round the corner
  65. turtle.forward()
  66. turtle.turnRight()
  67. turtle.forward()
  68. turtle.forward()
  69. turtle.turnRight()
  70. turtle.forward()
  71. end
Add Comment
Please, Sign In to add comment