Advertisement
meuced

bucheron_v2

Jul 1st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    
  2.  
  3.     local temporisation = 300               --secondes åA0 attendre entre chaque ligne
  4.     local niveauFuelMini = 100              -- niveau de dåA9placements auquel on doit refaire le plein de fuel
  5.     local niveauCharbonMini = 11            -- quantitåA9 de charbons restants åA0 laquelle on doit refaire le plein de charbon
  6.     local niveauSaplingMini = 10
  7.     local saplingSlot = 1
  8.     local premierSlot = 2                                   -- premier slot oåB9 se trouve le minerai ramassåA9
  9.     local dernierSlot = 15                                  -- dernier slot åA0 surveiller pour enclencher le vidage de l'inventaire
  10.     local charbonSlot = 16
  11.     local direction = 0
  12.      
  13.     function verifFuel()                                    -- våA9rifie si on a assez de fuel (dåA9placements) en råA9serve.
  14.       -- 1 charbon = 96 deplacements
  15.       -- On våA9rifie le niveau de fuel
  16.                     local niveauFuel = turtle.getFuelLevel()
  17.                     if (niveauFuel ~= "unlimited") then
  18.                                     if (niveauFuel < niveauFuelMini) then
  19.                                                     -- On a besoin de faire le plein
  20.                                                     turtle.select(charbonSlot)
  21.                                                     turtle.refuel(5) -- on recharge
  22.                                                     -- et on våA9rifie si il nous reste assez de charbon
  23.                                                     if turtle.getItemCount(charbonSlot) < niveauCharbonMini then
  24.                                                                     return rechargeCharbon() -- on refait le plein de charbon
  25.                                                     end
  26.                                     end
  27.                     end
  28.     end
  29.      
  30.     function rechargeSapling()
  31.      
  32.             --on se remet en direction "un", face au coffre
  33.             while direction ~= 1 do
  34.                             turtle.turnRight()
  35.                             direction=direction+1
  36.                             if direction == 4 then direction = 0 end
  37.             end
  38.      
  39.             turtle.select(saplingSlot)
  40.      
  41.             turtle.suck(20)
  42.      
  43.             --on se remet en direction "zåA9ro"
  44.             while direction ~= 0 do
  45.                     turtle.turnRight()
  46.                     direction=direction+1
  47.                     if direction == 4 then direction = 0 end
  48.             end
  49.      
  50.             if turtle.getItemCount(saplingSlot) < 6 then
  51.                     print("Merci de remettre des saplings !")
  52.                     print("Appuez sur ENTREE pour reprendre.")
  53.                     local a = read()
  54.             end
  55.      
  56.     end
  57.      
  58.     function rechargeCharbon()
  59.      
  60.                     --on prend du charbon dans le coffre au-dessus de la tortue
  61.                     turtle.select(charbonSlot)
  62.                     turtle.suckUp()
  63.                     if turtle.getItemCount(charbonSlot) < 6 then
  64.                             print("Merci de remettre du charbon !")
  65.                             print("Appuez sur ENTREE pour reprendre.")
  66.                             local a = read()
  67.                     end
  68.                     turtle.select(charbonSlot)
  69.                     turtle.refuel(5) -- on recharge
  70.     end
  71.      
  72.     function videInventaire()
  73.                
  74.                     --on se remet en direction "deux", face au coffre
  75.                     --while direction ~= 2 do
  76.                             --      turtle.turnRight()
  77.                             --      direction=direction+1
  78.                             --      if direction == 4 then direction = 0 end
  79.                     --end
  80.                
  81.                     --on vide l'inventaire
  82.                     for slot=premierSlot,dernierSlot do
  83.                                     turtle.select(slot)
  84.                                     while turtle.getItemCount(slot) > 0 do
  85.                                                     turtle.drop(turtle.getItemCount(slot))
  86.                                                     if turtle.getItemCount(slot) > 0 then
  87.                                                                     sleep(0.5)
  88.                                                     end
  89.                                     end
  90.                     end
  91.                
  92.                     --on se remet en direction "zåA9ro"
  93.                     --while direction ~= 0 do
  94.                             --      turtle.turnRight()
  95.                             --      direction=direction+1
  96.                             --      if direction == 4 then direction = 0 end
  97.                     --end
  98.      
  99.     end
  100.      
  101.      
  102.     verifFuel()
  103.     turtle.forward()
  104.     while true do
  105.             turtle.select(1)
  106.             turtle.turnRight()
  107.             if turtle.compare() == false then
  108.                     for i=1,8 do
  109.                             turtle.dig()
  110.                             if i ~= 8 then
  111.                                     turtle.digUp()
  112.                                     turtle.up()
  113.                             end
  114.                     end
  115.                     for i=1,7 do
  116.                             turtle.down()
  117.                     end
  118.                     turtle.suck()
  119.                     turtle.place()
  120.             end
  121.             turtle.turnLeft()
  122.             for i=1, 3 do
  123.                     if turtle.forward() == false then
  124.                             turtle.turnLeft()
  125.                             turtle.forward()
  126.                             turtle.turnLeft()
  127.                             verifFuel()
  128.                             --if turtle.getItemCount(dernierSlot) > 0 then
  129.                             videInventaire()
  130.                             --end
  131.                             if turtle.getItemCount(saplingSlot) < niveauSaplingMini then
  132.                                     rechargeSapling()
  133.                             end
  134.                             sleep(temporisation)
  135.                             turtle.forward()
  136.                             break
  137.                     end
  138.             end
  139.             sleep(0.1)
  140.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement