Advertisement
Guest User

minage

a guest
Dec 11th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 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(zta)
  27. print(zbu)
  28.     print("orientation:"..orientation)
  29. end
  30. function Corientation(o)
  31.     while orientation ~= o do
  32. turtle.turnLeft()
  33. orientation = orientation+1
  34. if orientation == 4 then
  35. orientation = 0
  36. end
  37. afficheinfo()
  38. end
  39. end
  40.  
  41. function deplacementY(y2)
  42. yb = tonumber(y2)
  43. while yb ~= y3 do
  44. if yb < y3 then
  45. if not turtle.down() then
  46. turtle.digDown()
  47. else
  48. y3 = y3-1
  49. afficheinfo()
  50. end
  51. else
  52. if not turtle.up() then
  53. turtle.digUp()
  54. else
  55. y3 = y3+1
  56. afficheinfo()
  57. end
  58. end
  59.         end
  60. end
  61. function deplacementZ(z2)
  62.  
  63. if z3 > z2 then
  64. Corientation(1)
  65. else
  66. Corientation(3)
  67. end
  68.  
  69. while z3 ~= z2 do
  70. if not turtle.forward() then
  71.     turtle.dig()
  72. else
  73.  
  74. if orientation == 3 then
  75. z3 = z3+1
  76. afficheinfo()
  77. elseif orientation == 1 then
  78. z3 = z3-1
  79. afficheinfo()
  80. end
  81. end
  82. end
  83. end
  84.  
  85. function deplacementX(x2)
  86.  
  87. if x3 > x2 then
  88. Corientation(2)
  89. else
  90. Corientation(0)
  91. end
  92. while x3 ~= x2 do
  93. if not turtle.forward() then
  94.     turtle.dig()
  95. else
  96. print("h")
  97. afficheinfo()
  98. if orientation == 0 then
  99. x3 = x3+1
  100. afficheinfo()
  101. elseif orientation == 2 then
  102. x3 = x3-1
  103. afficheinfo()
  104. end
  105. end
  106. end
  107. end
  108. function deplacement(xa,ya,za)
  109. deplacementY(ya)
  110. deplacementX(xa)
  111. deplacementZ(za)
  112. end
  113. function vidage()
  114.     XT = x3
  115.     YT = y3
  116.     ZT = z3
  117.     deplacement(0,0,0)
  118.     Corientation(2)
  119. for slot=1,15 do
  120.  turtle.select(slot)
  121.  while turtle.getItemCount(slot) > 0 do
  122.  turtle.drop(turtle.getItemCount(slot))
  123.  if turtle.getItemCount(slot) > 0 then
  124. sleep(0.5)
  125.  end
  126.                
  127. end  
  128. end            
  129. deplacement(XT,YT,ZT)
  130.  
  131. end
  132.  
  133. function minage()
  134. zr = false
  135. zta = zbu
  136. for i2 = 0, ybu do
  137. for i1 = 0, zbu do
  138. if x3 == 0 then
  139. deplacementX(xbu)
  140. else
  141. deplacementX(0)
  142. end
  143.  
  144. if zr == true then
  145. zta = zta-1
  146. deplacementZ(zta)
  147. if zta >= 0 then
  148. zr = false
  149. end
  150. else
  151. deplacementZ(i1)
  152. end
  153. end
  154. deplacementY(i2)
  155. if zr == false then zr = true
  156. elseif zr == true then
  157. zr = false
  158. end
  159. end
  160. deplacement(0,0,0)
  161. Corientation(0)
  162. end
  163. --deplacementY(1)
  164. minage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement