Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Programme de Minage en tunnel sur le nombre de blocks voulu
- -- http://pastebin.com/CiyHEnUd
- -- fonction refuel
- local niveauFuelMini = 5 -- niveau de déplacements auquel on doit refaire le plein de fuel
- local niveauCharbonMini = 1
- local slotBois = 1 -- foction inventaire
- local slotBoisDeVie = 2
- local enderchestCharbonSlot = 15
- local enderchestBois = 14
- local enderchestVidage = 13
- local charbonSlot = 16
- function verifFuel() -- vérifie si on a assez de fuel (déplacements) en réserve.
- -- 1 charbon = 96 deplacements
- -- On vérifie le niveau de fuel
- local niveauFuel = turtle.getFuelLevel()
- if (niveauFuel ~= "unlimited") then
- if (niveauFuel < niveauFuelMini) then
- -- On a besoin de faire le plein
- turtle.select(charbonSlot)
- turtle.refuel(1) -- on recharge pour 96 deplacements
- if turtle.getItemCount(charbonSlot) < niveauCharbonMini then
- rechargeCharbon() -- on refait le plein de charbon
- end
- end
- end
- end
- function rechargeCharbon() -- permet de refaire le plein en charbon
- turtle.select(enderchestCharbonSlot)
- turtle.placeUp()
- turtle.select(charbonSlot)
- turtle.suckUp()
- turtle.select(enderchestCharbonSlot)
- turtle.digUp()
- end
- function mineDevant()
- while turtle.detect() do turtle.dig() end
- end
- function movForward()
- while not turtle.forward() do
- sleep(1)
- end
- return true
- end
- function videInventaire() -- if turtle.getItemCount(dernierSlot) > 0
- local slot
- turtle.select(enderchestVidage)
- turtle.placeUp()
- turtle.select(slotBoisDeVie)
- while turtle.getItemCount(slotBoisDeVie) > 2 do
- turtle.dropUp(turtle.getItemCount(slotBoisDeVie))
- if turtle.getItemCount(slot) > 2 then
- sleep(0.5)
- end
- end
- turtle.select(enderchestVidage)
- turtle.digUp()
- end
- function turn(Str)
- if Str == "G" then turtle.turnRight()
- else turtle.turnLeft()
- end
- end
- function compare_mine()
- local detectbloc = turtle.detect()
- if detectbloc == false then
- turtle.select(slotBois)
- detectLevelBois()
- turtle.place()
- end
- if detectbloc == true then
- turtle.select(slotBoisDeVie)
- if turtle.compare() == true then
- detectLevelBoisDeVie()
- turtle.dig()
- turtle.select(slotBois)
- detectLevelBois()
- turtle.place()
- turtle.select(slotBoisDeVie)
- end
- end
- end
- function detectLevelBois()
- -- controle du niveau avant de poser
- turtle.select(slotBois)
- if turtle.getItemCount(slotBois) < 2 then
- turtle.select(enderchestBois)
- turtle.placeUp()
- turtle.select(slotBois)
- turtle.suckUp()
- turtle.select(enderchestBois)
- turtle.digUp()
- turtle.select(slotBois)
- end
- end
- function detectLevelBoisDeVie()
- -- controle du niveau avant de prendre
- turtle.select(slotBoisDeVie)
- if turtle.getItemCount(slotBoisDeVie) > 5 then
- videInventaire()
- end
- end
- --********************************************--
- --********** Programme principal *************--
- --********************************************--
- -- Début du minage
- verifFuel()
- while true do
- local x = 0
- while x < 11 do
- print("x: "..x)
- verifFuel()
- movForward()
- turn("G")
- compare_mine()
- turn("D")
- x=x+1
- end
- movForward()
- turn("G")
- local x = 0
- while x < 3 do
- print("x: "..x)
- verifFuel()
- movForward()
- turn("G")
- compare_mine()
- turn("D")
- x=x+1
- end
- movForward()
- turn("G")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement