Advertisement
Zonkotron

Miner V0.2

Mar 5th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. length = 0
  2. count = 0
  3.  
  4. args = {...}
  5.  
  6. if args[1] == "0" or args[1] == nil then
  7. print("Korrektes Format lautet: mine <Ganglaenge> <Anzahl Abzweigungen> " )
  8. print("Ebefalls moeglich: mine <Ganglaenge>")
  9. print("Nix zu tun, fahre herunter !")
  10. return(0)
  11. else
  12. length = args[1]+0 -- bugfixes string
  13. end
  14.  
  15. if args[2] == "0" or args[2] == nil then
  16. count = 0
  17. else
  18. count = args[2]+0
  19. end
  20.  
  21. print("Fuehre aus: Zonkotron Miner V 0.2")
  22. print("Loescher Boehren!")
  23. print("Laenge:".. length)
  24. print("count:" .. count)
  25.  
  26.  
  27.  
  28.  
  29. function turn() -- Turns 180
  30. turtle.turnRight()
  31. turtle.turnRight()
  32. end
  33.  
  34. function lDig(x) -- Digs a tunnel 2 spaces below cleared room
  35.  
  36. for i=1,x,1 do
  37.  
  38. if turtle.detect() then
  39. turtle.dig()
  40. end
  41.  
  42. turtle.forward()
  43.  
  44. if turtle.detectDown() then
  45. turtle.digDown()
  46. end
  47.  
  48.  
  49. end -- end of for 1,x,1
  50.  
  51. end -- end of tDig()
  52.  
  53.  
  54.  
  55. function tDig(x) -- Digs a tunnel 3 label set ZONK
  56.  
  57. for i=1,x,1 do
  58.  
  59. while turtle.detect() do
  60. turtle.dig()
  61. sleep(0.5)
  62. end
  63.  
  64. turtle.forward()
  65.  
  66. if turtle.detectDown() then
  67. turtle.digDown()
  68. end
  69.  
  70. while turtle.detectUp() do
  71. turtle.digUp()
  72. sleep(0.5)
  73. end
  74.  
  75. end -- end of for 1,x,1
  76.  
  77. end -- end of tDig()
  78.  
  79.  
  80.  
  81. function sDig(y) -- Digs in a straight line
  82.  
  83. for i=1,y,1 do
  84.  
  85. if turtle.detect() then
  86. turtle.dig()
  87. end
  88.  
  89. turtle.forward()
  90.  
  91. end
  92.  
  93. end -- end function
  94.  
  95. function uDig(x) -- Digs an upper 2 high clearance tunnel
  96.  
  97. for i=1,x,1 do
  98.  
  99. while turtle.detect() do
  100. turtle.dig()
  101. sleep(0.5)
  102. end
  103.  
  104. if turtle.detectDown() then
  105. turtle.digDown()
  106. end
  107.  
  108. turtle.forward()
  109.  
  110. end -- end of for 1,x,1
  111.  
  112. end -- end of tDig()
  113.  
  114. -- Start Hauptprogramm
  115.  
  116.  
  117. if count == nil or count == 0 then
  118. for i=1,3,1 do
  119. while turtle.detectUp() do
  120. turtle.digUp()
  121. sleep(0.5)
  122. end
  123. turtle.up()
  124. end
  125. uDig(length)
  126. turn()
  127.  
  128. for i=1,2,1 do
  129. if turtle.detectDown() then
  130. turtle.digDown()
  131. end
  132. turtle.down()
  133. end
  134. if turtle.detectDown() then
  135. turtle.digDown()
  136. end
  137. lDig(length)
  138. turtle.down()
  139. turn()
  140.  
  141.  
  142. else
  143. for i=1,count,1 do
  144.  
  145. turtle.turnRight()
  146.  
  147. for i=1,3,1 do
  148. while turtle.detectUp() do
  149. turtle.digUp()
  150. sleep(0.5)
  151. end
  152. turtle.up()
  153. end
  154.  
  155. uDig(length)
  156. turn()
  157.  
  158. for i=1,2,1 do
  159. if turtle.detectDown() then
  160. turtle.digDown()
  161. end
  162. turtle.down()
  163. end
  164.  
  165. if turtle.detectDown() then
  166. turtle.digDown()
  167. end
  168.  
  169. lDig(length)
  170. turtle.down()
  171. turtle.turnRight()
  172.  
  173. for i=1,4,1 do
  174. turtle.forward()
  175. if turtle.detect() then
  176. print("Tunnel End,Aborting Branch process")
  177. return(0)
  178. end
  179. end
  180.  
  181. end
  182.  
  183. end
  184. print("Finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement