Kierra

Untitled

Apr 7th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. --- Variables
  2.  
  3. nombreLignes = 0
  4. longueurLignes = 0
  5. cache = 0
  6. slot = 0
  7. item = 0
  8. slot = 16
  9.  
  10. --- Récupération des variables
  11.  
  12. -- Nombre de lignes
  13. print("Combien de lignes fera votre turtle ?")
  14. nombreLignes = read()
  15. nombreLignes = tonumber(nombreLignes)
  16.  
  17. -- Longueur des lignes
  18. print("Quelle seront les longueurs de vos tunnels ?")
  19. cache = read()
  20. cache = tonumber(cache)
  21.  
  22. --- Functions
  23.  
  24. function ligne()
  25. while longueurLignes ~= 0 do
  26. turtle.dig()
  27. sleep(0.3)
  28. turtle.forward()
  29. turtle.digUp()
  30. sleep(0.3)
  31. turtle.digDown()
  32. longueurLignes = longueurLignes - 1
  33. end
  34. end
  35.  
  36. function Cache()
  37. longueurLignes = cache
  38. end
  39.  
  40. function turn()
  41. turtle.turnRight()
  42. turtle.turnRight()
  43. end
  44.  
  45. function Return()
  46. while longueurLignes ~= 0 do
  47. turtle.forward()
  48. longueurLignes = longueurLignes - 1
  49. end
  50. end
  51.  
  52. function nextline()
  53. sleep(0.1)
  54. turtle.turnRight()
  55. turtle.dig()
  56. turtle.digUp()
  57. sleep(0.3)
  58. turtle.forward()
  59. turtle.dig()
  60. turtle.digUp()
  61. sleep(0.3)
  62. turtle.forward()
  63. turtle.dig()
  64. turtle.digUp()
  65. sleep(0.3)
  66. turtle.forward()
  67. turtle.turnRight()
  68. end
  69.  
  70. function enderchest()
  71. item = turtle.getItemCount(16)
  72. if item > 0 then
  73. turtle.select(2)
  74. turtle.dig()
  75. turtle.place()
  76. while slot ~= 3 do
  77. turtle.select(slot)
  78. turtle.drop()
  79. slot = slot - 1
  80. end
  81. slot = 16
  82. item = 0
  83. turtle.dig()
  84. turtle.select(1)
  85. end
  86. end
  87.  
  88. function refuel()
  89. fuel = turtle.getFuelLevel()
  90. if fuel < 200 then
  91. turtle.select(1)
  92. turtle.refuel(1)
  93. end
  94. end
  95.  
  96. --- Programmes
  97.  
  98. while nombreLignes ~= 0 do
  99. Cache()
  100. refuel()
  101. ligne()
  102. turn()
  103. Cache()
  104. Return()
  105. nextline()
  106. enderchest()
  107. nombreLignes = nombreLignes - 1
  108. end
Advertisement
Add Comment
Please, Sign In to add comment