Advertisement
M0n5t3r

Get_tree

Jun 29th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. local counter = 0
  2. local log_counter = 0
  3.  
  4. function getTree()
  5. local goUp = 0
  6. local success, t = turtle.inspect()
  7. if success then
  8. if (string.find(t.name, "leaves") == nil) then
  9. if string.find(t.name, "rubberwood.log") then
  10. turtle.dig()
  11. if turtle.forward() == false then
  12. turtle.dig()
  13. turtle.forward()
  14. else
  15. if turtle.detectUp() == true then
  16. while (turtle.detectUp()) do
  17. local success, t = turtle.inspectUp()
  18. if (string.find(t.name, "leaves") == nil) then
  19. turtle.digUp()
  20. log_counter = log_counter + 1
  21. turtle.up()
  22. goUp = goUp + 1
  23. else
  24. break
  25. end
  26. end
  27. if goUp > 0 then
  28. repeat
  29. turtle.down()
  30. goUp = goUp - 1
  31. until goUp == 0
  32. end
  33. else
  34. if goUp > 0 then
  35. repeat
  36. turtle.down()
  37. goUp = goUp - 1
  38. until goUp == 0
  39. end
  40. end
  41. turtle.up()
  42. turtle.select(1)
  43. turtle.placeDown()
  44. turtle.back()
  45. turtle.down()
  46. if turtle.getItemCount(1) > 1 then
  47. if string.find(turtle.getItemDetail(1).name, "sapling") then
  48. turtle.placeDown()
  49. end
  50. end
  51. goBack()
  52. end
  53. end
  54. end
  55. end
  56. end
  57.  
  58. function goBack()
  59. counter = counter + 1
  60. print("Tree's done: " .. counter .. " | Logs gotten:" .. log_counter)
  61.  
  62. end
  63.  
  64. while true do
  65. getTree()
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement