Advertisement
Guest User

minage6

a guest
Dec 12th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. x3 = 0
  2. yam = 0
  3. xam = 0
  4. zam = 0
  5. ybu = 0
  6. xbu = 0
  7. zbu = 0
  8. y3 = 0
  9. orientation = 0
  10. z3 = 0
  11. print("Longeur :")
  12.  
  13. xbu = tostring(read())
  14. xbu = tonumber(xbu)
  15. print("Largeur :")
  16. zbu = tostring(read())
  17. zbu = tonumber(zbu)
  18. --zbu = 4
  19. print("hauteur : ")
  20. ybu = tonumber(read())
  21. function afficheinfo()
  22.     term.clear()
  23.     print("X:"..x3)
  24.     print("Y:"..y3)
  25.     print("Z:"..z3)
  26. print(pair)
  27. print(zbu)
  28. print(vidage1)
  29.     print("orientation:"..orientation)
  30. end
  31. function Corientation(o)
  32.     while orientation ~= o do
  33. turtle.turnLeft()
  34. orientation = orientation+1
  35. if orientation == 4 then
  36. orientation = 0
  37. end
  38. afficheinfo()
  39. end
  40. end
  41.  
  42. function deplacementY(y2)
  43. yb = tonumber(y2)
  44. while yb ~= y3 do
  45. if yb < y3 then
  46. if not turtle.down() then
  47. turtle.digDown()
  48.     if turtle.getItemCount(15) > 0 then
  49.     vidage()
  50.     end
  51. else
  52. y3 = y3-1
  53. afficheinfo()
  54. end
  55. else
  56. if not turtle.up() then
  57. turtle.digUp()
  58.     if turtle.getItemCount(15) > 0 then
  59.     vidage()
  60.     end
  61. else
  62. y3 = y3+1
  63. afficheinfo()
  64. end
  65. end
  66.         end
  67. end
  68. function deplacementZ(z2)
  69.  
  70. if z3 > z2 then
  71. Corientation(1)
  72. else
  73. Corientation(3)
  74. end
  75.  
  76. while z3 ~= z2 do
  77. if not turtle.forward() then
  78.     turtle.dig()
  79.         if turtle.getItemCount(15) > 0 then
  80.     vidage()
  81.     end
  82. else
  83.  
  84. if orientation == 3 then
  85. z3 = z3+1
  86. afficheinfo()
  87. elseif orientation == 1 then
  88. z3 = z3-1
  89. afficheinfo()
  90. end
  91. end
  92. end
  93. end
  94.  
  95. function deplacementX(x2)
  96.  
  97. if x3 > x2 then
  98. Corientation(2)
  99. else
  100. Corientation(0)
  101. end
  102. while x3 ~= x2 do
  103. if not turtle.forward() then
  104.     turtle.dig()
  105.     if turtle.getItemCount(15) > 0 then
  106.     vidage()
  107.     end
  108. else
  109. print("h")
  110. afficheinfo()
  111. if orientation == 0 then
  112. x3 = x3+1
  113. afficheinfo()
  114. elseif orientation == 2 then
  115. x3 = x3-1
  116. afficheinfo()
  117. end
  118. end
  119. end
  120. end
  121. function deplacement(xa,ya,za)
  122. deplacementY(ya)
  123. deplacementX(xa)
  124. deplacementZ(za)
  125. end
  126. function vidage()
  127. vidage1 = true
  128. print("vidage")
  129.     XT = x3
  130.     YT = y3
  131.     ZT = z3
  132.     deplacement(0,0,0)
  133.     Corientation(2)
  134. for slot=1,15 do
  135.  turtle.select(slot)
  136.  while turtle.getItemCount(slot) > 0 do
  137.  turtle.drop(turtle.getItemCount(slot))
  138.  if turtle.getItemCount(slot) > 0 then
  139. sleep(0.5)
  140.  end
  141.                
  142. end  
  143. end            
  144. turtle.select(1)
  145. deplacement(1,YT,ZT)
  146. vidage1 = false
  147. end
  148.  
  149.  
  150. function minage()
  151. pair = true
  152. repeat
  153. repeat
  154. if pair == false then
  155. but = 1
  156. if x3 == xbu then
  157. deplacementX(1)
  158. else
  159. deplacementX(xbu)
  160. end
  161. deplacementZ(z3-1)
  162. elseif pair == true then
  163. but = zbu
  164. if x3 == xbu then
  165. deplacementX(1)
  166. else
  167. deplacementX(xbu)
  168. end
  169. deplacementZ(z3+1)
  170. end
  171. until z3 == but
  172. if x3 == 1 then
  173. deplacementX(xbu)
  174. else
  175. deplacementX(1)
  176. end
  177. if pair == true then
  178. pair = false
  179. elseif pair == false then
  180. pair = true
  181. end
  182. if y3 == ybu then
  183. break
  184. else
  185. deplacementY(y3+1)
  186. end
  187. until y3 >= ybu
  188. deplacement(0,0,0)
  189. Corientation(0)
  190. end
  191. deplacement(1,1,4)
  192. vidage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement