Advertisement
Zonkotron

turtle 2

Jan 23rd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. length = 0
  2. count = 0
  3. Abstand = 0
  4.  
  5. args = {...}
  6.  
  7. if args[1] == "0" or args[1] == nil then
  8.  
  9. print("Korrektes Format lautet: Programmname <Ganglaenge> <Anzahl Abzweigungen> <Abstand Gänge> " )
  10. print("Ebefalls moeglich: Programmname <Ganglaenge>")
  11. print("Nix zu tun, fahre herunter !")
  12. return(0)
  13.  
  14. else
  15.  
  16. length = args[1]+0 -- bugfixes string
  17.  
  18. end
  19.  
  20.  
  21.  
  22. if args[2] == "0" or args[2] == nil then
  23.  
  24. count = 0
  25.  
  26. else
  27.  
  28. count = args[2]+0
  29.  
  30. end
  31.  
  32. if args[3] == "0"or args[3] == nil then
  33.  
  34. Abstand = 0
  35.  
  36. else
  37.  
  38. Abstand = args[3]+1
  39.  
  40. end
  41.  
  42. print("Fuehre aus: Zonkotron Miner V 0.2")
  43. print("Loescher Boehren!")
  44. print("Laenge:".. length)
  45. print("count:" .. count)
  46.  
  47.  
  48.  
  49.  
  50. function turn() -- Turns 180
  51.  
  52. turtle.turnRight()
  53. turtle.turnRight()
  54.  
  55. end
  56.  
  57.  
  58.  
  59.  
  60. function lDig(x) -- Digs a tunnel 2 spaces below cleared room
  61.  
  62. for i=1,x,1 do
  63.  
  64. if turtle.detect() then
  65. turtle.dig()
  66. end
  67.  
  68. turtle.forward()
  69.  
  70. if turtle.detectDown() then
  71. turtle.digDown()
  72. end
  73.  
  74.  
  75. end
  76.  
  77. end
  78.  
  79.  
  80.  
  81. function tDig(x) -- Digs a tunnel 3 label set ZONK
  82.  
  83. for i=1,x,1 do
  84.  
  85. while turtle.detect() do
  86.  
  87. turtle.dig()
  88. sleep(0.5)
  89.  
  90. end
  91.  
  92. turtle.forward()
  93.  
  94. if turtle.detectDown() then
  95.  
  96. turtle.digDown()
  97. end
  98.  
  99. while turtle.detectUp() do
  100.  
  101. turtle.digUp()
  102. sleep(0.5)
  103. end
  104.  
  105. end
  106.  
  107. end
  108.  
  109.  
  110.  
  111.  
  112. function sDig(y) -- Digs in a straight line
  113.  
  114. for i=1,y,1 do
  115.  
  116. if turtle.detect() then
  117.  
  118. turtle.dig()
  119.  
  120. end
  121.  
  122. turtle.forward()
  123.  
  124. end
  125.  
  126. end
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133. function uDig(x) -- Digs an upper 2 high clearance tunnel
  134.  
  135. for i=1,x,1 do
  136.  
  137. while turtle.detect() do
  138. turtle.dig()
  139. sleep(0.5)
  140. end
  141.  
  142. if turtle.detectDown() then
  143. turtle.digDown()
  144. end
  145.  
  146. turtle.forward()
  147.  
  148. end
  149. end
  150.  
  151. function Gangherstellen()
  152.  
  153. for i=1,3,1 do
  154.  
  155. while turtle.detectUp() do
  156.  
  157. turtle.digUp()
  158. sleep(0.5)
  159.  
  160. end
  161.  
  162. turtle.up()
  163. end
  164.  
  165. uDig(1)
  166. turn()
  167.  
  168. for i=1,2,1 do
  169.  
  170. if turtle.detectDown() then
  171.  
  172. turtle.digDown()
  173.  
  174. end
  175.  
  176. turtle.down()
  177.  
  178. end
  179.  
  180. if turtle.detectDown() then
  181.  
  182. turtle.digDown()
  183.  
  184. end
  185.  
  186. lDig(1)
  187. turtle.down()
  188. turn()
  189.  
  190.  
  191. end
  192.  
  193.  
  194.  
  195.  
  196.  
  197. -- Start Hauptprogramm
  198.  
  199.  
  200. if count == nil or count == 0 then
  201.  
  202. for i=1,3,1 do
  203.  
  204. while turtle.detectUp() do
  205.  
  206. turtle.digUp()
  207. sleep(0.5)
  208.  
  209. end
  210.  
  211. turtle.up()
  212. end
  213.  
  214. uDig(length)
  215. turn()
  216.  
  217. for i=1,2,1 do
  218.  
  219. if turtle.detectDown() then
  220.  
  221. turtle.digDown()
  222.  
  223. end
  224.  
  225. turtle.down()
  226.  
  227. end
  228.  
  229. if turtle.detectDown() then
  230.  
  231. turtle.digDown()
  232.  
  233. end
  234.  
  235. lDig(length)
  236. turtle.down()
  237. turn()
  238.  
  239.  
  240. else
  241. for i=1,count,1 do
  242.  
  243. turtle.turnRight()
  244.  
  245. for i=1,3,1 do
  246.  
  247. while turtle.detectUp() do
  248.  
  249. turtle.digUp()
  250. sleep(0.5)
  251. end
  252.  
  253. turtle.up()
  254.  
  255. end
  256.  
  257. uDig(length)
  258. turn()
  259.  
  260. for i=1,2,1 do
  261.  
  262. if turtle.detectDown() then
  263.  
  264. turtle.digDown()
  265. end
  266.  
  267. turtle.down()
  268. end
  269.  
  270. if turtle.detectDown() then
  271.  
  272. turtle.digDown()
  273. end
  274.  
  275. lDig(length)
  276. turtle.down()
  277. turtle.turnRight()
  278.  
  279. for i=1,Abstand,1 do
  280.  
  281. turtle.forward()
  282.  
  283. if turtle.detect() then
  284.  
  285. Gangherstellen()
  286.  
  287.  
  288. end
  289. end
  290.  
  291. end
  292.  
  293. end
  294. print("Finished!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement