Advertisement
OJPAE

Untitled

Jun 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. --Code quarry--
  2. local long = 0 --Longuer de creuse--
  3. local larg = 0 --Largeur de creuse--
  4. local haut = 0 --Hauteur de creuse--
  5. local way = 0 --Gauche ou droite--
  6. local sens = 0
  7. --Mettre des coffres dans le slot n° 1--
  8. local slot16 = turtle.getItemCount(16) --Nombre d'items dans le slot 16--
  9.  
  10.  
  11. local function forwardM()
  12.  
  13. repeat
  14.  
  15. if turtle.detect() then
  16.  
  17. turtle.dig()
  18.  
  19. end
  20.  
  21. if turtle.forward() then
  22.  
  23. TF = TF - 1
  24.  
  25. end
  26.  
  27. if slot16 > 0 then
  28.  
  29. turtle.select(2)
  30. turtle.digUp()
  31. turtle.placeUp()
  32.  
  33. for slot = 5, 16 do
  34.  
  35. turtle.select(slot)
  36. turtle.dropUp()
  37. sleep(1.5)
  38.  
  39. end
  40.  
  41. turtle.select(2)
  42. turtle.digUp()
  43.  
  44. end
  45.  
  46. until TF == 0
  47.  
  48. TS = TS - 1
  49.  
  50. end
  51.  
  52.  
  53. local function turn()
  54.  
  55. if sens == 0 then
  56.  
  57. turtle.turnLeft()
  58. turtle.dig()
  59. turtle.forward()
  60. turtle.turnLeft()
  61. sens = 1
  62.  
  63. else
  64.  
  65. turtle.turnRight()
  66. turtle.dig()
  67. turtle.forward()
  68. turtle.turnRight()
  69. sens = 0
  70.  
  71. end
  72.  
  73. end
  74.  
  75.  
  76. local function recall()
  77.  
  78. if way == 0 and sens == 1 then
  79.  
  80. turtle.turnLeft()
  81. repeat
  82.  
  83. turtle.forward()
  84. TSB = TSB - 1
  85.  
  86. until TSB == 0
  87.  
  88. turtle.turnRight()
  89.  
  90. repeat
  91.  
  92. turtle.forward()
  93. TB = TB - 1
  94.  
  95. until TB == 0
  96.  
  97. turtle.turnRight()
  98. turtle.turnRight()
  99.  
  100. if turtle.detectUp() then
  101.  
  102. turtle.digUp()
  103.  
  104. end
  105.  
  106. turtle.up()
  107. end
  108.  
  109. else if way == 0 and sens == 0 then
  110.  
  111. turtle.turnRight()
  112. repeat
  113.  
  114. turtle.forward()
  115. TSB = TSB - 1
  116.  
  117. until TSB == 0
  118.  
  119. turtle.turnLeft()
  120.  
  121. if turtle.detectUp() then
  122.  
  123. turtle.digUp()
  124.  
  125. end
  126.  
  127. turtle.up()
  128. end
  129.  
  130. else if way == 1 and sens == 1 then
  131.  
  132. turtle.turnRight()
  133. repeat
  134.  
  135. turtle.forward()
  136. TSB = TSB - 1
  137.  
  138. until TSB == 0
  139.  
  140. turtle.turnLeft()
  141. repeat
  142.  
  143. turtle.forward()
  144. TB = TB - 1
  145.  
  146. until TB == 0
  147.  
  148. turtle.turnRight()
  149. turtle.turnRight()
  150.  
  151. if turtle.detectUp() then
  152.  
  153. turtle.digUp()
  154.  
  155. end
  156.  
  157. turtle.up()
  158. end
  159.  
  160. else
  161.  
  162. turtle.turnRight()
  163. repeat
  164.  
  165. turtle.forward()
  166. TSB = TSB - 1
  167.  
  168. until TSB == 0
  169.  
  170. turtle.turnRight()
  171. turtle.turnRight()
  172.  
  173. if turtle.detectUp() then
  174.  
  175. turtle.digUp()
  176.  
  177. end
  178.  
  179. turtle.up()
  180.  
  181. end
  182.  
  183.  
  184. local function resetF()
  185.  
  186. if TS ~= 0 then
  187. TF = long
  188. end
  189.  
  190. end
  191.  
  192.  
  193. local function start()
  194.  
  195. repeat
  196.  
  197. repeat
  198.  
  199. forwardM()
  200. turn()
  201. resetF()
  202.  
  203. until TF == 0 and TS == 0
  204.  
  205. recall()
  206. reset()
  207.  
  208. until haut == 0 and TF == 0 and TS == 0
  209.  
  210. end
  211.  
  212.  
  213. --Start--
  214. print("Entrez la longueur à creuser (en face de la turtle) :")
  215. input = io.read()
  216. long = tonumber(input)
  217. print("Entrez la largeur à creuser (à gauche/droite de la turtle) :")
  218. input2 = io.read()
  219. larg = tonumber(input2)
  220. print("Entrez la hauteur à creuser :")
  221. input3 = io.read()
  222. haut = tonumber(input3)
  223. print("Creuser vers la gauche ou vers la droite ?")
  224. print("0 = Gauche // 1 = Droite")
  225. input4 = io.read()
  226. way = tonumber(input4)
  227. TF = long
  228. TB = long
  229. TS = larg
  230. TSB = larg
  231. sens = way
  232. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement