Advertisement
Guest User

mining

a guest
Nov 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. tArgs = { ... }
  2.  
  3. if #tArgs ~= 2 then
  4. print( "Anwendung: stripmine <Laenge> <Reihen>" )
  5. return
  6. end
  7.  
  8. length = tonumber(tArgs[1])
  9. amount = tonumber(tArgs[2])
  10.  
  11. if length < 0 then
  12. print("Die Laenge muss positiv sein.")
  13. return
  14. end
  15.  
  16. if amount < 0 then
  17. print("Die Anzahl der Reihen muss positiv sein.")
  18. return
  19. end
  20.  
  21. function checkSpace()
  22. if turtle.getItemCount(14) == 1 then
  23. back()
  24. unload()
  25. proceed()
  26. end
  27. end
  28.  
  29. function forward()
  30. while not turtle.forward() do
  31. turtle.dig()
  32. turtle.attack()
  33. sleep(0.1)
  34. end
  35. end
  36.  
  37. function unload()
  38. print( "Inventar leeren..." )
  39. for n = 1,14 do
  40. turtle.select(n)
  41. turtle.drop()
  42. end
  43. turtle.select(1)
  44. end
  45.  
  46. function checkFuel()
  47. if turtle.getFuelLevel() <= 10 then
  48. turtle.select(15)
  49. turtle.refuel(1)
  50. turtle.select(1)
  51. end
  52. end
  53.  
  54. function placeTorch()
  55. turtle.select(16)
  56. turtle.placeDown()
  57. turtle.select(1)
  58. end
  59.  
  60. function stripper()
  61. xSteps = 0
  62. xPos = 0
  63. placeTorch()
  64. for i = 1, length do
  65. turtle.dig()
  66. checkSpace()
  67. forward()
  68. xPos = xPos + 1
  69. checkFuel()
  70. turtle.digDown()
  71. checkSpace()
  72. if xSteps == 12 then
  73. placeTorch()
  74. xSteps = 0
  75. else
  76. xSteps = xSteps + 1
  77. end
  78. end
  79. placeTorch()
  80. end
  81.  
  82. function turn()
  83. turtle.turnRight()
  84. turtle.turnRight()
  85. end
  86.  
  87. function back()
  88. turn()
  89. for i = 1, xPos do
  90. forward()
  91. end
  92. if zPos > 0 then
  93. turtle.turnRight()
  94. for i = 1, zPos do
  95. forward()
  96. end
  97. turtle.turnLeft()
  98. end
  99. end
  100.  
  101. function proceed()
  102. turtle.turnLeft()
  103. for i = 1, zPos do
  104. forward()
  105. end
  106. turtle.turnLeft()
  107. for i = 1, xPos do
  108. forward()
  109. end
  110. end
  111.  
  112. function row()
  113. row = 0
  114. zSteps = 0
  115. zPos = 0
  116. for i = 1, amount do
  117. row = row + 1
  118. if row == 1 then
  119. stripper()
  120. back()
  121. else
  122. turtle.turnLeft()
  123. if zPos ~= 0 then
  124. for i = 1, zPos do
  125. forward()
  126. checkFuel()
  127. end
  128. end
  129. for i = 1,3 do
  130. turtle.dig()
  131. checkSpace()
  132. forward()
  133. zPos = zPos + 1
  134. zSteps = zSteps + 1
  135. checkFuel()
  136. turtle.digDown()
  137. checkSpace()
  138. end
  139. turtle.turnLeft()
  140. stripper()
  141. back()
  142. end
  143. end
  144. unload()
  145. end
  146.  
  147. checkFuel()
  148. turtle.digDown()
  149. checkSpace()
  150. row()
  151. turn()
  152. print("Auftrag beendet, Massa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement