Advertisement
astrixswayer

tunelier_LES

Jul 13th, 2014
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. -- tunelier_LES
  2.  
  3. local stoc_fuel = 0
  4. local stoc_fuel_min = 8
  5. local stoc_mur = 0
  6. local stoc_mur_min = 13
  7. local stoc_lum = 0
  8. local stoc_lum_min = 3
  9. local longueur = 0
  10. local lum = 2
  11. local toto = swagg
  12.  
  13. function minage()
  14.  
  15.     turtle.select(1)
  16.    
  17.     -- centre
  18.     turtle.dig()
  19.     turtle.forward()
  20.     longueur = longueur - 1
  21.     lum = lum - 1
  22.     turtle.digUp()
  23.     turtle.up()
  24.     --centre
  25.     --haut
  26.     turtle.turnLeft()
  27.     turtle.digUp()
  28.     turtle.placeUp()
  29.     turtle.dig()
  30.     turtle.forward()
  31.     --haut
  32.     --haut-gauche
  33.     turtle.digUp()
  34.     turtle.placeUp()
  35.     turtle.dig()
  36.     turtle.place()
  37.     turtle.digDown()
  38.     turtle.down()
  39.     --haut-gauche
  40.     --gauche
  41.     if lum == 0 then
  42.         turtle.dig()
  43.         turtle.select(2)
  44.         turtle.place()
  45.         turtle.select(1)
  46.         turtle.digDown()
  47.         turtle.down()
  48.     else
  49.         turtle.dig()
  50.         turtle.place()
  51.         turtle.digDown()
  52.         turtle.down()
  53.     end
  54.     --gauche
  55.     --bas-gauche
  56.     turtle.dig()
  57.     turtle.place()
  58.     turtle.digDown()
  59.     turtle.placeDown()
  60.     turtle.turnLeft()
  61.     turtle.turnLeft()
  62.     turtle.dig()
  63.     turtle.forward()
  64.     --bas-gauche
  65.     --bas
  66.     turtle.dig()
  67.     turtle.digDown()
  68.     turtle.placeDown()
  69.     turtle.forward()
  70.     --bas
  71.     --bas-droite
  72.     turtle.digUp()
  73.     turtle.dig()
  74.     turtle.place()
  75.     turtle.digDown()
  76.     turtle.placeDown()
  77.     turtle.up()
  78.     --bas-droite
  79.     --droite
  80.     if lum == 0 then
  81.         turtle.digUp()
  82.         turtle.dig()
  83.         turtle.select(2)
  84.         turtle.place()
  85.         turtle.select(1)
  86.         turtle.digDown()
  87.         turtle.up()
  88.     else
  89.         turtle.digUp()
  90.         turtle.dig()
  91.         turtle.place()
  92.         turtle.digDown()
  93.         turtle.up()
  94.         print(toto)
  95.     end
  96.     --droite
  97.     --haut-droite
  98.     turtle.digUp()
  99.     turtle.placeUp()
  100.     turtle.dig()
  101.     turtle.place()
  102.     turtle.back()
  103.     turtle.down()
  104.     turtle.turnLeft()
  105.     --haut-droite
  106.     --lum
  107.     if lum == 0 then
  108.         lum = 5
  109.     end
  110.     --lum
  111. end
  112.  
  113. function rf()
  114.    
  115.     local fuel_min = 15
  116.     local fuel_level = 0
  117.    
  118.     turtle.select(16)
  119.     fuel_level = turtle.getFuelLevel()
  120.    
  121.     print(fuel_level)
  122.    
  123.     if fuel_level < fuel_min then
  124.        
  125.         turtle.refuel(1)
  126.         fuel_level = turtle.getFuelLevel()
  127.         print(fuel_level)
  128.        
  129.     end
  130. end
  131.  
  132. function rechest()
  133.    
  134.     local comp = false
  135.     local rechest_dist = 0
  136.     local item_rf = 0
  137.     local item_lum = 0
  138.    
  139.     turtle.turnLeft()
  140.     turtle.turnLeft()
  141.     turtle.select(15)
  142.    
  143.     while comp == false do
  144.        
  145.         rf()
  146.         turtle.forward()
  147.         turtle.select(15)
  148.         comp = turtle.compare()
  149.         rechest_dist = rechest_dist + 1
  150.        
  151.     end
  152.    
  153.     turtle.turnRight()
  154.     turtle.select(2)
  155.     stoc_lum = turtle.getItemCount()
  156.    
  157.     item_lum = 64 - stoc_lum
  158.    
  159.     turtle.suck(item_lum)
  160.    
  161.     turtle.turnLeft()
  162.    
  163.     turtle.select(3)
  164.     turtle.drop(64)
  165.     turtle.select(4)
  166.     turtle.drop(64)
  167.     turtle.select(5)
  168.     turtle.drop(64)
  169.     turtle.select(6)
  170.     turtle.drop(64)
  171.     turtle.select(7)
  172.     turtle.drop(64)
  173.     turtle.select(8)
  174.     turtle.drop(64)
  175.     turtle.select(9)
  176.     turtle.drop(64)
  177.     turtle.select(10)
  178.     turtle.drop(64)
  179.     turtle.select(11)
  180.     turtle.drop(64)
  181.     turtle.select(12)
  182.     turtle.drop(64)
  183.     turtle.select(13)
  184.     turtle.drop(64)
  185.    
  186.     turtle.select(16)
  187.     stoc_fuel = turtle.getItemCount()
  188.    
  189.     item_rf = 64 - stoc_fuel
  190.    
  191.     turtle.turnLeft()
  192.     turtle.suck(item_rf)
  193.    
  194.     stoc_lum = turtle.getItemCount()
  195.    
  196.     turtle.turnLeft()
  197.    
  198.     while rechest_dist > 0 do
  199.        
  200.         rf()
  201.         turtle.forward()
  202.         rechest_dist = rechest_dist - 1
  203.        
  204.     end
  205.    
  206. end
  207.  
  208.  
  209.  
  210. print("slot 1 : block mur")
  211. print("slot 2 : block lumiere")
  212. print("slot 15 : type chest")
  213. print("slot 16 : fuel")
  214. print("longueur ?")
  215.  
  216. pt = io.read()
  217.  
  218. longueur = tonumber(pt)
  219.  
  220. while longueur > 0 do
  221.    
  222.     turtle.select(16)
  223.     stoc_fuel = turtle.getItemCount()
  224.     turtle.select(1)
  225.     stoc_mur = turtle.getItemCount()
  226.     turtle.select(2)
  227.     stoc_lum = turtle.getItemCount()
  228.    
  229.     if stoc_fuel > stoc_fuel_min and stoc_mur > stoc_mur_min and stoc_lum > stoc_lum_min then
  230.    
  231.         rf()
  232.        
  233.         minage()
  234.        
  235.         print("longueur restante = "..longueur)
  236.         print("lum = "..lum)
  237.        
  238.     else
  239.    
  240.         rechest()
  241.    
  242.     end
  243. end
  244.  
  245. print("FIN")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement