Kierra

Untitled

Apr 6th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. --- Variables ---
  2.  
  3. x = 0 -- Variable définitive longueur
  4. z = 0 -- Variable définitive largeur
  5. DirHori = -1 -- Orientation de la turtle horizontalement
  6. DirVert = -1 -- Orientation de la turtle verticalement
  7. x2 = 0 -- Variable dynamique sur la longueur
  8. z2 = 0 -- Variable dynamique sur la largeur
  9. enderchest = 1 -- Slot de l'enderchest
  10. slot = 16 -- Slots de la turtle
  11.  
  12.  
  13. --- Récupération des variables
  14.  
  15. print("Quelle sera la longueur de votre trou ?")
  16. x = read()
  17. x = tonumber(x)
  18. x2 = x - 1
  19.  
  20. print("Quelle sera la largeur de votre trou ?")
  21. z = read()
  22. z = tonumber(z)
  23. z2 = z - 1
  24.  
  25. --- Refuel ---
  26.  
  27. turtle.refuel(5)
  28.  
  29. --- Fonctions ---
  30.  
  31. function inventaire() -- Pose de l'enderchest quand l'inventaire est plein
  32. if turtle.getItemSpace(16)>0 then
  33. turtle.select(enderchest)
  34. turtle.place()
  35. while slot ~= 0 do
  36. turtle.drop()
  37. slot = slot - 1
  38. end
  39. turtle.dig()
  40. slot = 16
  41. end
  42. end
  43.  
  44. function ligne() -- Forage d'une ligne (longueur en fonction de x)
  45. x2 = x
  46. while x2 ~= 0 do
  47. while turtle.detect() do
  48. turtle.dig()
  49. sleep(0.2)
  50. end
  51. turtle.forward()
  52. x2 = x2 - 1
  53. end
  54. end
  55.  
  56. function fDirVert() -- Définition de l'orientation à prendre après le forage d'une couche
  57. if DirVert>0 then
  58. turtle.turnRight()
  59. turtle.digDown()
  60. turtle.down()
  61. elseif DirVert<0 then
  62. turtle.turnLeft()
  63. turtle.digDown()
  64. turtle.down()
  65. end
  66. end
  67.  
  68. function fDirHori() -- Définition de l'orientation à choisir après le forage d'une ligne en fonction de la variable ori
  69. if DirHori>0 then
  70. turtle.turnRight()
  71. turtle.dig()
  72. turtle.forward()
  73. turtle.turnRight()
  74. elseif DirHori<0 then
  75. turtle.turnLeft()
  76. turtle.dig()
  77. turtle.forward()
  78. turtle.turnLeft()
  79. end
  80. end
  81.  
  82. function fInvertDirHori() -- Choix de l'orientation horizontale. Inversion de la bascule.
  83. DirHori = DirHori * -1
  84. end
  85.  
  86. function fInvertDirVert()
  87. DirVert = DirVert * -1
  88. end
  89.  
  90. --- Programme ---
  91.  
  92. while true do
  93. while z2 ~= 0 do
  94. ligne()
  95. fDirHori()
  96. fInvertDirHori()
  97. z2 = z2 - 1
  98. end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment