Advertisement
OJPAE

Untitled

Jun 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 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 turtle.getItemCount(16)>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 == 1
  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 == 1
  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.  
  108. end
  109.  
  110. if way == 0 and sens == 0 then
  111.  
  112. turtle.turnRight()
  113. repeat
  114.  
  115. turtle.forward()
  116. TSB = TSB - 1
  117.  
  118. until TSB == 0
  119.  
  120. turtle.turnLeft()
  121.  
  122. if turtle.detectUp() then
  123.  
  124. turtle.digUp()
  125.  
  126. end
  127.  
  128. turtle.up()
  129.  
  130. end
  131.  
  132. if way == 1 and sens == 0 then
  133.  
  134. turtle.turnRight()
  135. repeat
  136.  
  137. turtle.forward()
  138. TSB = TSB - 1
  139.  
  140. until TSB == 0
  141.  
  142. turtle.turnLeft()
  143. repeat
  144.  
  145. turtle.forward()
  146. TB = TB - 1
  147.  
  148. until TB == 1
  149.  
  150. turtle.turnRight()
  151. turtle.turnRight()
  152.  
  153. if turtle.detectUp() then
  154.  
  155. turtle.digUp()
  156.  
  157. end
  158.  
  159. turtle.up()
  160.  
  161. end
  162.  
  163. if way == 1 and sens == 1 then
  164.  
  165. turtle.turnRight()
  166. repeat
  167.  
  168. turtle.forward()
  169. TSB = TSB - 1
  170.  
  171. until TSB == 0
  172.  
  173. turtle.turnRight()
  174. turtle.turnRight()
  175.  
  176. if turtle.detectUp() then
  177.  
  178. turtle.digUp()
  179.  
  180. end
  181.  
  182. turtle.up()
  183. end
  184. end
  185.  
  186.  
  187.  
  188. local function resetF()
  189.  
  190. if TS ~= 0 then
  191. TF = long
  192. end
  193.  
  194. end
  195.  
  196.  
  197. local function reset()
  198.  
  199. TF = long
  200. TB = long
  201. TS = larg
  202. TSB = larg
  203. sens = way
  204.  
  205. end
  206.  
  207.  
  208. local function start()
  209.  
  210. repeat
  211.  
  212. repeat
  213.  
  214. forwardM()
  215. turn()
  216. resetF()
  217.  
  218. until TF == 1 and TS == 0
  219.  
  220. recall()
  221. haut = haut - 1
  222. reset()
  223.  
  224. until haut == 0
  225.  
  226. os.shutdown()
  227.  
  228. end
  229.  
  230.  
  231. --Start--
  232. print("Entrez la longueur à creuser (en face de la turtle) :")
  233. input = io.read()
  234. long = tonumber(input)
  235. print("Entrez la largeur à creuser (à gauche/droite de la turtle) :")
  236. input2 = io.read()
  237. larg = tonumber(input2)
  238. print("Entrez la hauteur à creuser :")
  239. input3 = io.read()
  240. haut = tonumber(input3)
  241. print("Creuser vers la gauche ou vers la droite ?")
  242. print("0 = Gauche // 1 = Droite")
  243. input4 = io.read()
  244. way = tonumber(input4)
  245. TF = long
  246. TB = long
  247. TS = larg
  248. TSB = larg
  249. sens = way
  250. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement