Advertisement
Guest User

m15

a guest
Dec 10th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. x3 = 0
  2. y3 = 0
  3. orientation = 0
  4. z3 = 0
  5. print("Longeur :")
  6. --x = tonumber(read())
  7. print("Largeur :")
  8. z = tonumber(read())
  9. function afficheinfo()
  10.     term.clear()
  11.     print("X:"..x3)
  12.     print("Y:"..y3)
  13.     print("Z:"..z3)
  14.     print("orientation:"..orientation)
  15. end
  16. function Corientation(o)
  17.     while orientation ~= o do
  18. turtle.turnLeft()
  19. orientation = orientation+1
  20. if orientation == 4 then
  21. orientation = 0
  22. end
  23. afficheinfo()
  24. end
  25. end
  26.  
  27. function deplacementY(y2)
  28. yb = tonumber(y2)
  29. while yb ~= y3 do
  30. if yb < y3 then
  31. if not turtle.down() then
  32. turtle.digDown()
  33. else
  34. turtle.down()
  35. y3 = y3-1
  36. afficheinfo()
  37. end
  38. else
  39. if not turtle.up() then
  40. turtle.digUp()
  41. else
  42. turtle.up()
  43. y3 = y3+1
  44. afficheinfo()
  45. end
  46. end
  47.         end
  48. end
  49. function deplacementZ(z2)
  50.     z2 = tonumber(z2)
  51.     if z3 > z2 then
  52. Corientation(1)
  53. else
  54. Corientation(3)
  55. end
  56. while z3 ~= z2 do
  57. if not turtle.forward() then
  58. turtle.dig()
  59. turtle.forward()
  60. if orientation == 3 then
  61. z3 = z3+1
  62. afficheinfo()
  63. elseif orientation == 1 then
  64. z3 = z3-1
  65. afficheinfo()
  66. end
  67. else
  68. turtle.forward()
  69. if orientation == 3 then
  70. z3 = z3+1
  71. afficheinfo()
  72. elseif orientation == 1 then
  73. z3 = z3-1
  74. afficheinfo()
  75. end
  76. end
  77. end
  78. end
  79. function deplacementX(x2)
  80. if x3 > x2 then
  81. Corientation(2)
  82. else
  83. Corientation(0)
  84. end
  85. while x3 ~= x2 do
  86. if not turtle.forward() then
  87. turtle.dig()
  88. turtle.forward()
  89. if orientation == 0 then
  90. x3 = x3+1
  91. afficheinfo()
  92. elseif orientation == 2 then
  93. x3 = x3-1
  94. afficheinfo()
  95. end
  96. else
  97. turtle.forward()
  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.                                 end
  127.                
  128. end                
  129. deplacement(XT,YT,ZT)
  130.  
  131. end
  132.  
  133. deplacement(0,0,2)
  134. vidage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement