Advertisement
Guest User

Minage Opti

a guest
Jul 29th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.43 KB | None | 0 0
  1. --- Programme : Minage optimisé 2.0
  2. --- Auteur : MaitreKierra
  3. ---     Dernière édition : 12/04/13
  4. --- Note : Utilisation libre. Faites en ce que vous voulez :)
  5.  
  6. --- Variables
  7.  
  8. nombreLignes = 0
  9. longueurLignes = 0
  10. cache = 0
  11. slot = 0
  12. item = 0
  13. slot = 16
  14.  
  15. --- Récupération des variables
  16.  
  17.         -- Nombre de lignes
  18.         print("Nombre de ligne:")
  19.                 nombreLignes = read()
  20.                 nombreLignes = tonumber(nombreLignes)
  21.        
  22.         -- Longueur des lignes
  23.         print("Longueur des lignes:")
  24.                 cache = read()
  25.                 cache = tonumber(cache)
  26.                
  27. --- Functions
  28.  
  29. function ligne()
  30.         while longueurLignes ~= 0 do
  31.                 turtle.dig()
  32.                 sleep(0.3)
  33.                 turtle.forward()
  34.                 turtle.digUp()
  35.                 sleep(0.3)
  36.                 turtle.digDown()
  37.                 longueurLignes = longueurLignes - 1
  38.                 item = turtle.getItemCount(16)
  39.                 if item > 0 then
  40.                  turtle.turnLeft()
  41.                  turtle.select(2)
  42.                  turtle.dig()
  43.                  turtle.place()
  44.                  turtle.select(3)
  45.                  turtle.drop()
  46.                  turtle.select(4)
  47.                  turtle.drop()
  48.                  turtle.select(5)
  49.                  turtle.drop()
  50.                  turtle.select(6)
  51.                  turtle.drop()
  52.                  turtle.select(7)
  53.                  turtle.drop()
  54.                  turtle.select(8)
  55.                  turtle.drop()
  56.                  turtle.select(9)
  57.                  turtle.drop()
  58.                  turtle.select(10)
  59.                  turtle.drop()
  60.                  turtle.select(11)
  61.                  turtle.drop()
  62.                  turtle.select(12)
  63.                  turtle.drop()
  64.                  turtle.select(13)
  65.                  turtle.drop()
  66.                  turtle.select(14)
  67.                  turtle.drop()
  68.                  turtle.select(15)
  69.                  turtle.drop()
  70.                  turtle.select(16)
  71.                  turtle.drop()
  72.                  turtle.select(1)
  73.                  turtle.turnRight()
  74.                 end
  75.         end
  76. end
  77.  
  78.  
  79. function Cache()
  80.         longueurLignes = cache
  81. end
  82.  
  83. function turn()
  84.         turtle.turnRight()
  85.         turtle.turnRight()
  86. end
  87.  
  88. function Return()
  89.         while longueurLignes ~= 0 do
  90.                   turtle.forward()
  91.                   longueurLignes = longueurLignes - 1
  92.                   if turtle.detect() then
  93.                     turtle.dig()
  94.                   end
  95.         end
  96. end
  97.  
  98.  function enderchest()
  99.         item = turtle.getItemCount(16)
  100.         if item > 0 then
  101.                 turtle.select(2)
  102.                 turtle.dig()
  103.                 turtle.place()
  104.                 while slot ~= 1 do
  105.                         turtle.select(3)
  106.                         turtle.drop()
  107.                         turtle.select(4)
  108.                         turtle.drop()
  109.                         turtle.select(5)
  110.                         turtle.drop()
  111.                         turtle.select(6)
  112.                         turtle.drop()
  113.                         turtle.select(7)
  114.                         turtle.drop()
  115.                         turtle.select(8)
  116.                         turtle.drop()
  117.                         turtle.select(9)
  118.                         turtle.drop()
  119.                         turtle.select(10)
  120.                         turtle.drop()
  121.                         turtle.select(11)
  122.                         turtle.drop()
  123.                         turtle.select(12)
  124.                         turtle.drop()
  125.                         turtle.select(13)
  126.                         turtle.drop()
  127.                         turtle.select(14)
  128.                         turtle.drop()
  129.                         turtle.select(15)
  130.                         turtle.drop()
  131.                         turtle.select(16)
  132.                         turtle.drop()
  133.                         turtle.select(1)
  134.                 end
  135.         end
  136. end
  137.  
  138. function nextline()
  139.         sleep(0.1)
  140.         turtle.turnRight()
  141.         turtle.dig()
  142.         turtle.digUp()
  143.         sleep(0.3)
  144.         turtle.forward()
  145.         turtle.dig()
  146.         turtle.digUp()
  147.         sleep(0.3)
  148.         turtle.forward()
  149.         turtle.dig()
  150.         turtle.digUp()
  151.         sleep(0.3)
  152.         turtle.forward()
  153.         turtle.turnRight()
  154. end
  155.  
  156. function refuel()
  157.         fuel = turtle.getFuelLevel()
  158.         if fuel < 200 then
  159.                 turtle.select(1)
  160.                 turtle.refuel(1)
  161.         end
  162. end
  163.                
  164. --- Programme
  165.  
  166. while nombreLignes ~= 0 do    
  167.         Cache()
  168.         refuel()
  169.         ligne()
  170.         turn()
  171.         Cache()
  172.         Return()
  173.         nextline()
  174.         nombreLignes = nombreLignes - 1
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement