Advertisement
OJPAE

Untitled

Jun 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 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.  
  108. else if way == 0 and sens == 0 then
  109.  
  110. turtle.turnRight()
  111. repeat
  112.  
  113. turtle.forward()
  114. TSB = TSB - 1
  115.  
  116. until TSB == 0
  117.  
  118. turtle.turnLeft()
  119.  
  120. if turtle.detectUp() then
  121.  
  122. turtle.digUp()
  123.  
  124. end
  125.  
  126. turtle.Up()
  127.  
  128. end
  129.  
  130. end
  131.  
  132. local function resetF()
  133.  
  134. if TS ~= 0 then
  135. TF = long
  136. end
  137.  
  138. end
  139.  
  140.  
  141. local function start()
  142.  
  143. repeat
  144.  
  145. repeat
  146.  
  147. forwardM()
  148. turn()
  149. resetF()
  150.  
  151. until TF == 0 and TS == 0
  152.  
  153. recall()
  154. reset()
  155.  
  156. until haut == 0 and TF == 0 and TS == 0
  157.  
  158. end
  159.  
  160.  
  161. --Start--
  162. print("Entrez la longueur à creuser (en face de la turtle) :")
  163. input = io.read()
  164. long = tonumber(input)
  165. print("Entrez la largeur à creuser (à gauche/droite de la turtle) :")
  166. input2 = io.read()
  167. larg = tonumber(input2)
  168. print("Entrez la hauteur à creuser :")
  169. input3 = io.read()
  170. haut = tonumber(input3)
  171. print("Creuser vers la gauche ou vers la droite ?")
  172. print("0 = Gauche // 1 = Droite")
  173. input4 = io.read()
  174. way = tonumber(input4)
  175. TF = long
  176. TB = long
  177. TS = larg
  178. TSB = larg
  179. sens = way
  180. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement