Advertisement
RLPGhost

Minage Tunnel

Feb 2nd, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. -- Programme de Minage en tunnel sur le nombre de blocks voulu par RLP_Ghost
  2. -- http://pastebin.com/ZzEtVH3R
  3.  
  4. local charbonSlot = 16
  5. local touchSlot = 15
  6. local idChannel = 123
  7.  
  8. local niveauFuelMini = 5                                -- niveau de déplacements auquel on doit refaire le plein de fuel
  9. local niveauCharbonMini = 5
  10.  
  11.  
  12. -- fonction refuel  par cedmeu
  13.  
  14. function verifFuel()                                    -- vérifie si on a assez de fuel (déplacements) en réserve.
  15.   -- 1 charbon = 96 deplacements
  16.   -- On vérifie le niveau de fuel
  17.         local niveauFuel = turtle.getFuelLevel()
  18.         if (niveauFuel ~= "unlimited") then
  19.                 if (niveauFuel < niveauFuelMini) then
  20.                         -- On a besoin de faire le plein
  21.                         turtle.select(charbonSlot)
  22.                         turtle.refuel(1) -- on recharge pour 96 deplacements
  23.                 end
  24.         end
  25. end
  26.  
  27. function mineDevant()
  28.     if turtle.detect() then turtle.dig() end
  29. end
  30.  
  31. function mineHautBas()
  32.     if turtle.detectUp() then turtle.digUp() end
  33.     if turtle.detectDown() then turtle.digDown() end
  34. end
  35.  
  36.  
  37. --********************************************--
  38. --********** Programme principal *************--
  39. --********************************************--
  40.  
  41. print("Entrez la dimensions du Tunnel à miner.")
  42. print("")
  43. print("Longueur : ")
  44. longueur = tonumber(read())
  45.  
  46. modem = peripheral.wrap("left")
  47. modem.transmit(idChannel,idChannel,"etat:attente")
  48.  
  49. print("Appuyez sur [ENTREE] pour commencer !")
  50. read()
  51. modem.transmit(idChannel,idChannel,"etat:encours")
  52.  
  53. local l=1
  54. while l<=longueur do
  55.     print("Profondeur Tunnel: "..l)
  56.     modem.transmit(idChannel,idChannel,"prTunnel:"..l)
  57.     mineDevant()
  58.     verifFuel()
  59.     turtle.forward()
  60.     mineHautBas()
  61.     l = l+1
  62. end
  63.  
  64. -- Fin du tunnel , debut de retour
  65.  
  66. modem.transmit(idChannel,idChannel,"etat:retour")
  67. turtle.turnRight()
  68. turtle.turnRight()
  69.  
  70. -- demi-tour fait et revient
  71.  
  72. turtle.select(touchSlot)
  73. turtle.placeDown()
  74.  
  75. l=1
  76. local t=1
  77. while l<=longueur do
  78.     verifFuel()
  79.     mineDevant()
  80.     turtle.forward()
  81.     mineHautBas()
  82.     l = l+1
  83.     t = t+1
  84.     if ( t > 8 ) then
  85.             turtle.select(touchSlot)
  86.             turtle.placeDown()
  87.             t=0
  88.     end
  89. end
  90.  
  91. modem.transmit(idChannel,idChannel,"etat:fin")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement