Advertisement
tankflo

Untitled

Apr 26th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. a=1 --initialisation des coordonée
  2. verif=0
  3. block=1
  4. compteur=0
  5. bedrock=0
  6. tour=1
  7. droitegauche=1
  8. coin=1
  9. compteur2=1
  10. x2=0
  11. z2=0
  12.  
  13. term.clear()
  14. term.setCursorPos(1,1)
  15. rednet.open("right")
  16.  
  17.  
  18.  
  19.  
  20.  
  21. function avencer() --fonction qui permet d'avencer tout en envoyent des info au PC central
  22. turtle.forward()
  23. X=x2+X
  24. Z=z2+Z
  25. rednet.send(ID,X)
  26. rednet.send(ID,Z)
  27. rednet.send(ID,Y)
  28. end
  29.  
  30.  
  31.  
  32. function bas() --fonction qui permet de déssendre + envoie
  33. turtle.down()
  34. Y=Y-1
  35. rednet.send(ID,X)
  36. rednet.send(ID,Z)
  37. rednet.send(ID,Y)
  38. end
  39.  
  40.  
  41.  
  42.  
  43. function haut() --fonction qui permet de montée + envoie
  44. turtle.up()
  45. Y=Y+1
  46. rednet.send(ID,X)
  47. rednet.send(ID,Z)
  48. rednet.send(ID,Y)
  49. end
  50.  
  51.  
  52.  
  53.  
  54. function changement_de_direction() --fonction qui change la direction
  55. if droitegauche == 1 then
  56. if direction == "nord" or direction == "sud" then
  57. x2=z2*(-1)
  58. z2=0
  59. if direction == "nord" then
  60. direction = "est"
  61. end
  62. if direction == "sud" then
  63. direction = "west"
  64. end
  65. end
  66. if direction == "est" or direction == "ouest" then
  67. x2=z2
  68. z2=0
  69. if direction == "est" then
  70. direction = "sud"
  71. end
  72. if direction == "west" then
  73. direction = "nord"
  74. end
  75. end
  76. turtle.turnRight()
  77. end
  78.  
  79. if droitegauche == 0 then
  80. if direction == "nord" or direction == "sud" then
  81. x2=0
  82. z2=z2*(-1)
  83. if direction == "nord" then
  84. direction = "ouest"
  85. end
  86. if direction == "sud" then
  87. direction = "est"
  88. end
  89. end
  90. if direction == "est" or direction == "ouest" then
  91. x2=0
  92. z2=z2*(-1)
  93. if direction == "est" then
  94. direction = "nord"
  95. end
  96. if direction == "west" then
  97. direction = "sud"
  98. end
  99. end
  100. turtle.turnLeft()
  101. end
  102. end
  103.  
  104.  
  105. print("ID=?") --initialisation des coordonée + envoie + ID
  106. ID = io.read()
  107. print("X=?")
  108. X = io.read()
  109. print("Y=?")
  110. Y = io.read()
  111. print("Z=?")
  112. Z = io.read()
  113. envoie()
  114.  
  115. while x2==0 and z2==0 do --direction initial
  116. print("direction:")
  117. direction = read()
  118. if direction == "west" then
  119. x2=-1
  120. z2=0
  121. end
  122. if direction == "est" then
  123. x2=1
  124. z2=0
  125. end
  126. if direction == "nord" then
  127. x2=0
  128. z2=-1
  129. end
  130. if direction == "west" then
  131. x2=0
  132. z2=1
  133. end
  134. end
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142. while a==a do --Début des préparatif
  143. turtle.select(16)
  144. turtle.refuel(3)
  145. turtle.digUp()
  146. turtle.select(13)
  147. turtle.placeUp()
  148. while bedrock==0 do --Quand la turtle doit déssendre
  149. turtle.select(8)
  150. if turtle.compareDown()then
  151. bedrock=1
  152. end
  153. turtle.digDown()
  154. bas()
  155. while compteur<4 do
  156. compteur = compteur + 1
  157. while block<8 do
  158. turtle.select(block)
  159. block = block + 1
  160. if turtle.compare() then
  161. turtle.dig()
  162. end
  163. end
  164. block=1
  165. changement_de_direction()
  166. end
  167. compteur=0
  168. turtle.select(8)
  169. end
  170.  
  171. while bedrock==1 do --quand la turtle se vide et se déplace en surface
  172. turtle.select(13)
  173. if turtle.compareUp()then
  174. while block<13 do
  175. turtle.select(block)
  176. block = block + 1
  177. turtle.dropUp(63-turtle.getItemSpace())
  178. end
  179. block=1
  180. turtle.select(12)
  181. turtle.transferTo(16,63-turtle.getItemSpace())
  182. bedrock=0
  183. else
  184. turtle.digUp()
  185. haut()
  186. end
  187. if bedrock==0 then
  188. if tour==compteur2 then
  189. tour=tour+2
  190. compteur2=1
  191. if droitegauche==1 then
  192. changement_de_direction()
  193. turtle.dig()
  194. avencer()
  195. turtle.dig()
  196. avencer()
  197. turtle.dig()
  198. avencer()
  199. changement_de_direction()
  200. droitegauche=0
  201. else
  202. changement_de_direction()
  203. turtle.dig()
  204. avencer()
  205. turtle.dig()
  206. avencer()
  207. turtle.dig()
  208. avencer()
  209. changement_de_direction()
  210. droitegauche=1
  211. end
  212. else
  213. coin=(tour+2)/2
  214. if coin==compteur2 then
  215. if droitegauche==0 then
  216. changement_de_direction()
  217. else
  218. changement_de_direction()
  219.  
  220. end
  221. end
  222. end
  223. compteur2=compteur2+1
  224. turtle.dig()
  225. avencer()
  226. turtle.dig()
  227. avencer()
  228. turtle.dig()
  229. avencer()
  230. turtle.placeUp()
  231. end
  232. end
  233. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement