Kierra

Untitled

Apr 6th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 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
  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
  19.  
  20. print("Quelle sera la largeur de votre trou ?")
  21. z = read()
  22. z = tonumber(z)
  23. z2 = z
  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.turnRight()
  60. turtle.digDown()
  61. turtle.down()
  62. elseif dirVert<0 then
  63. turtle.turnLeft()
  64. turtle.turnLeft()
  65. turtle.digDown()
  66. turtle.down()
  67. end
  68. end
  69.  
  70. function fdirHori() -- Définition de l'orientation à choisir après le forage d'une ligne en fonction de la variable ori
  71. if dirHori>0 then
  72. turtle.turnRight()
  73. turtle.dig()
  74. turtle.forward()
  75. turtle.turnRight()
  76. elseif dirHori<0 then
  77. turtle.turnLeft()
  78. turtle.dig()
  79. turtle.forward()
  80. turtle.turnLeft()
  81. end
  82. end
  83.  
  84. function InvertDirHori() -- Choix de l'orientation horizontale. Inversion de la bascule.
  85. dirHori = dirHori * -1
  86. end
  87.  
  88. function InvertDirVert()
  89. dirVert = dirVert * -1
  90. end
  91.  
  92. --- Programme ---
  93.  
  94. while true do
  95. while z2 ~= 0 do
  96. fDirHori()
  97. fInvertDirHori()
  98. ligne()
  99. inventaire()
  100. z2 = z2 - 1
  101. end
  102. fDirVert()
  103. end
Advertisement
Add Comment
Please, Sign In to add comment