iiburukibun

Link the Wood Chopper

May 2nd, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. local WaitTime = 60
  2. local WentUp = 0
  3.  
  4. -- Detect
  5. local function Detect()
  6. if turtle.detect() then
  7. print("Tree!")
  8. return true
  9. else
  10. print("Not Tree!")
  11. return false
  12. end
  13. end --Detect()
  14.  
  15. -- ChopUp
  16. local function ChopUp(Count)
  17. if turtle.digUp() then
  18. if Count then
  19. WentUp = WentUp + 1
  20. print("Up: " .. WentUp)
  21. end
  22. return true
  23. else
  24. return false
  25. end
  26. end --ChopUp()
  27.  
  28. -- ChopDown
  29. local function ChopDown(Count)
  30. if Count then
  31. if WentUp > 0 then
  32. turtle.digDown()
  33. WentUp = WentUp - 1
  34. print("Down: " .. WentUp)
  35. return true
  36. else
  37. return false
  38. end
  39. else
  40. turtle.digDown()
  41. return true
  42. end
  43. end --ChopDown()
  44.  
  45. -- ChopForward
  46. local function ChopForward()
  47. if turtle.dig() then
  48. print("Forward")
  49. return true
  50. else
  51. return false
  52. end
  53. end -- ChopForward()
  54.  
  55. -- Main Loop
  56. while true do
  57. local Detected = false
  58.  
  59. Detected = Detect()
  60. if Detected then
  61. ChopForward()
  62. turtle.forward()
  63.  
  64. --Clear Stump
  65. ChopDown(false)
  66.  
  67. local StillWood
  68. StillWood = true
  69. while StillWood do
  70. StillWood = ChopUp(true)
  71. if StillWood then
  72. turtle.up()
  73. end
  74. end --StillWood (up)
  75.  
  76. ChopForward()
  77. turtle.forward()
  78.  
  79. StillWood = true
  80. while StillWood do
  81. StillWood = ChopDown(true)
  82. turtle.down()
  83. end --StillWood (down)
  84.  
  85. -- Clear Stump
  86. ChopDown(false)
  87.  
  88. -- WentUp = 0
  89.  
  90. turtle.turnRight()
  91. ChopForward()
  92. turtle.forward()
  93.  
  94. -- Clear Stump
  95. ChopDown(false)
  96.  
  97. StillWood = true
  98. while StillWood do
  99. StillWood = ChopUp(true)
  100. if StillWood then
  101. turtle.up()
  102. end
  103. end
  104.  
  105. turtle.turnRight()
  106. ChopForward()
  107. turtle.forward()
  108.  
  109. StillWood = true
  110. while StillWood do
  111. StillWood = ChopDown(true)
  112. turtle.down()
  113. end
  114.  
  115. -- Clear Stump
  116. ChopDown(false)
  117.  
  118. turtle.turnRight()
  119. turtle.forward()
  120. turtle.turnRight()
  121. turtle.back()
  122.  
  123. print("Done")
  124. end --Detected
  125.  
  126. -- Refuel
  127. if turtle.getFuelLevel() < 10000 then
  128. for Slot=1,16 do
  129. local NumberOfItems = turtle.getItemCount(Slot)
  130. turtle.refuel(NumberOfItems)
  131. end --for
  132. end --if
  133.  
  134. -- Store
  135. for Slot=1,16 do
  136. turtle.select(Slot)
  137. turtle.dropDown()
  138. end
  139.  
  140. redstone.setOutput("bottom", true)
  141. sleep(10)
  142. redstone.setOutput("bottom", false)
  143. sleep(WaitTime)
  144. end
Advertisement
Add Comment
Please, Sign In to add comment