Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- -- Controle des parametres
- local tArgs = { ... }
- if #tArgs == 0 then
- print("Hey biatch !! je vais ou ?")
- print("Syntaxe: Commande <longueur> <nb_de_tunnels>")
- return
- end
- -- Declaration des variables
- local length = tonumber(tArgs[1])
- local width = tonumber(tArgs[2])
- local slotNum = 0
- local loop = 0
- local retry = 0
- -- Plein d'energie
- if turtle.getFuelLevel() == 0 then
- turtle.select(16)
- print("Ajoutez du Carburant dans le dernier slot.")
- print("Entree pour continuer")
- ok = read()
- turtle.refuel()
- if turtle.getFuelLevel() == 0 then
- print("Boulay !! donne moi quelque chose a cramer pour avancer !!")
- return
- elseif turtle.getFuelLevel() == "unlimited" then
- print("Pwoua trop cheater meme pas besoin de cramer quelque chose pour foncer !!")
- return
- end
- elseif turtle.getFuelLevel() > 0 then
- print("Niveau de carburant : " .. turtle.getFuelLevel())
- turtle.select(16)
- print("Ajoutez du Carburant dans le dernier slot pour completer le plein.")
- print("Entree pour continuer")
- ok = read()
- turtle.refuel()
- end
- -- Blocs a ne pas miner
- print("Ajoutez des blocs a ne pas miner.")
- print("Entree pour continuer")
- ok = read()
- -- Fonction gestion des bocages
- function moveForward()
- if turtle.forward() == false then
- while turtle.dig() do
- end
- if turtle.forward() == false then
- print("Deplacement impossible")
- return false
- end
- return true
- end
- end
- -- ContrΓ΄le nombre de slot poubelle
- function countJunkSlot()
- junkSlots = 0
- i = 0
- while (i < 16) do
- i = i + 1
- if turtle.getItemCount(i) == 1 then
- junkSlots = junkSlots + 1
- end
- end
- end
- -- Fonction comparaison
- function compare()
- isJunkDown = false
- isJunkUp = false
- for i = 1, junkSlots do
- turtle.select(i)
- if turtle.compareUp()==true then
- isJunkUp = true
- end
- if turtle.compareDown()==true then
- isJunkDown = true
- end
- end
- end
- -- Fonction de minage
- function digger(n)
- print("Debut de la phase de minage.")
- purge = 0
- while (n > 0) do
- turtle.dig()
- moveForward()
- compare()
- if isJunkUp == false then
- turtle.digUp()
- put()
- end
- if isJunkDown == false then
- turtle.digDown()
- end
- --if purge == 10 then
- -- invPurge()
- -- purge = 0
- --end
- --purge = purge + 1
- n = n - 1
- end
- print("")
- end
- -- Fonction de retour sur la longueur
- function backL(n)
- print("Retour au coffre.")
- turtle.turnLeft()
- turtle.turnLeft()
- while (n > 0) do
- moveForward()
- n = n - 1
- end
- end
- -- Fonction de retour sur la largeur
- function backW(n)
- turtle.turnRight()
- while (n > 0)do
- moveForward()
- n = n - 1
- end
- turtle.turnLeft()
- end
- -- Fonction purge inventaire
- function invPurge()
- j = junkSlots
- while (j < 16) do
- j = j + 1
- for k = 1, junkSlots do
- turtle.select(j)
- if turtle.compareTo(k) == true then
- turtle.dropDown()
- end
- end
- end
- end
- -- Fonction repose de blocs
- function put()
- l = junkSlots
- place = false
- while (place == false) do
- l = l + 1
- --for m = 1, junkSlots do
- turtle.select(l)
- if turtle.compareTo(1) == true then
- turtle.placeUp()
- place = true
- end
- --end
- end
- end
- -- Fonction vidage dans le coffre
- function drop()
- invPurge()
- i = junkSlots
- while (i < 16) do
- i = i + 1
- turtle.select(i)
- turtle.drop()
- end
- end
- -- Fonction placement pour la ligne suivante
- function nextLine(n)
- turtle.turnLeft()
- while (n > 0) do
- turtle.dig()
- moveForward()
- turtle.digUp()
- n = n - 1
- end
- turtle.turnLeft()
- end
- -- Programme principal
- print("+--------------------------+")
- print("| Debut du minage |")
- print("+--------------------------+")
- print("")
- print("longueur des tunnels : " .. length)
- print("nombre de tunnels : " .. width)
- print("")
- countJunkSlot()
- digger(length)
- backL(length)
- drop()
- width = width - 1
- while (loop < width) do
- loop = loop + 1
- nextLine(loop)
- digger(length)
- backL(length)
- backW(loop)
- drop()
- end
- print("+--------------------------+")
- print("| Fin du minage |")
- print("+--------------------------+")
- print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement