tompy90

BranchMine

May 6th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. term.write("Branch depth: ")
  4. local length = io.read()
  5. term.setCursorPos(1,2)
  6. term.write("Number of branches: ")
  7. local number = io.read()
  8. term.clear()
  9.  
  10.  
  11. function forward()
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. print("Branch Mining...")
  15.  
  16. if turtle.getItemCount(13) > 0 or turtle.getItemCount(14) > 0 then
  17. unload()
  18. end
  19. while not turtle.forward() do
  20. if not turtle.dig() then
  21. sleep(1)
  22. end
  23. end
  24. end
  25.  
  26. function back()
  27. while not turtle.back() do
  28. sleep(1)
  29. end
  30. end
  31.  
  32. function left()
  33. turtle.turnLeft()
  34. end
  35.  
  36. function right()
  37. turtle.turnRight()
  38. end
  39.  
  40. function dig()
  41. turtle.digDown()
  42. while turtle.detectUp() do
  43. turtle.digUp()
  44. sleep(0.8)
  45. end
  46. end
  47.  
  48. function placeTorch()
  49. for i=1,14 do
  50. turtle.select(i)
  51. if turtle.compareTo(15) then
  52. turtle.placeDown()
  53. return
  54. end
  55. end
  56. end
  57.  
  58. function unload()
  59. turtle.select(16)
  60. turtle.digUp()
  61. turtle.placeUp()
  62. for i=1,14 do
  63. turtle.select(i)
  64. if not turtle.compareTo(15) then
  65. turtle.dropUp(turtle.getItemCount(i))
  66. end
  67. end
  68. turtle.select(1)
  69. end
  70.  
  71. function digLine()
  72. for i=1,4 do
  73. forward()
  74. dig()
  75. end
  76. back()
  77. back()
  78. left()
  79. placeTorch()
  80. for i=1,length do
  81. if i % 5 == 0 then
  82. placeTorch()
  83. end
  84. forward()
  85. dig()
  86. end
  87. right()
  88. placeTorch()
  89. for i=1,3 do
  90. forward()
  91. dig()
  92. end
  93. right()
  94. placeTorch()
  95. for i=1,length*2 do
  96. if i % 5 == 0 then
  97. placeTorch()
  98. end
  99. forward()
  100. dig()
  101. end
  102. right()
  103. placeTorch()
  104. for i=1,3 do
  105. forward()
  106. dig()
  107. end
  108. right()
  109. placeTorch()
  110. for i=1,length do
  111. if i % 5 == 0 then
  112. placeTorch()
  113. end
  114. forward()
  115. dig()
  116. end
  117. right()
  118. for i=1,4 do
  119. if i==3 then
  120. placeTorch()
  121. end
  122. forward()
  123. dig()
  124. end
  125. end
  126.  
  127. for i=1,number do
  128. digLine()
  129. end
Advertisement
Add Comment
Please, Sign In to add comment