Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- -- Initialisation
- print("+----------------------+")
- print("| Minage optimise |")
- print("+----------------------+")
- print("")
- print("")
- -- Declaration des variables
- nbJunkSlot = 0
- -- Fonction choix utilisateur
- function getParam()
- print("Altitude (Y) actuel de la turtle ?")
- initialY = read()
- print("Profondeur a miner ?")
- askHeight = read()
- maxHeight = initialY - 5
- if tonumber(askHeight) > maxHeight then
- print("Hauteur bridee a " .. maxHeight .. " pour ne pas attaquer la bedrock")
- height = maxHeight
- else
- height = askHeight
- end
- print("Longueur a miner ?")
- askLength = read()
- print("Largeur a miner ?")
- askWidth = read()
- estimateMove = (height / 3) * ((askLength * askWidth) + height)
- print("Nombre de mouvements : " .. math.floor(estimateMove))
- end
- -- Fonction estimation fuel
- function estimConsum()
- wooden_tool = math.floor(estimateMove / 10)
- lava = math.floor(estimateMove / 1000)
- blaze_rod = math.floor(estimateMove / 120)
- wood_block = math.floor(estimateMove / 15)
- stick = math.floor(estimateMove / 5)
- coal = math.floor(estimateMove / 80)
- mushroom_block = math.floor(estimateMove / 15)
- print(" +---------------+")
- print("Voici un | Conbustible | Blocs")
- print("tableau +---------------+")
- print("indicatif | Outil en bois | " .. wooden_tool)
- print("des quantitees | Lave | " .. lava)
- print("necessaires | Blaze | " .. blaze_rod)
- print("pour miner | Bloc de bois | " .. wood_block)
- print("sans tomber en | Stick | " .. stick)
- print("panne de | Charbon | " .. coal)
- print("combustible. | Bloc de champ | " .. mushroom_block)
- print(" +---------------+")
- end
- -- Controle fichier param
- function init()
- if fs.exist(mining.ini) == false then
- createParam()
- else
- r = fs.open("mining.ini","r")
- nbJunkslot = tonumber(r.readline(1))
- length = tonumber(r.readline(2))
- width = tonumber(r.readline(3))
- height = tonumber(r.readline(4))
- curX = tonumber(r.readline(5))
- curZ = tonumber(r.readline(6))
- curY = tonumber(r.readline(7))
- r.close()
- print("Reprendre le precedent minage :")
- print("nombre slot poubelle : " .. nbJunkslot)
- print("Longueur largeur hauteur : " .. lenght .. " " .. width .. " " .. height)
- print("Derniere position : " .. curX .. " " .. curZ .. " " .. curY)
- print("tapez y ou n")
- aws = read()
- if aws == n then
- deleteParam()
- createParam()
- elseif aws == y then
- -- appel fonction reprise minage
- else
- -- appel focntion abandon
- end
- end
- end
- -- Fonction creation fichiers param
- function createParam()
- f = fs.open("mining.ini","w")
- f.write(nbJunkSlot .. "\n" .. lenght .. "\n" .. width .. "\n" .. height .. "\n")
- f.close()
- c = fs.open("coords.nav","w")
- c.write("0\n0\n0\n")
- c.close()
- end
- -- Fonction suppression fichiers param
- function deleteParam()
- fs.delete("mining.ini")
- fs.delete("coords.nav")
- end
- -- Fonction abandon
- -- function abordMining()
- -- print("Abandon de la session.")
- -- return
- -- end
- -- Fonction deplacement avant
- function moveForward()
- if turtle.forward() == false then
- if turtle.dig() == false then
- print("Je suis coincé")
- elseif turtle.getFuelLevel == 0 then
- print("J'ai plus de carburant")
- else
- turtle.forward()
- end
- else
- end
- end
- -- Fonction plein d'energie
- function refuel()
- turtle.select(16)
- if turtle.getFuelLevel() == 0 then
- print("Placer du carburant dans le slot actif.")
- while (turtle.getItemCount(16) < 1) do
- sleep(0.5)
- end
- turtle.refuel()
- print("Niveau de carburant : " .. turtle.getFuelLevel())
- elseif turtle.getFuelLevel() > 0 then
- print("Niveau de carburant actuel : " .. turtle.getFuelLevel())
- print("Placer du carburant dans le slot actif")
- print("si vous souhaitez refaire le plein")
- print("et appuyez sur entree pour continuer.")
- ok = read()
- if turtle.getItemCount(16) > 0 then
- turtle.refuel()
- print("Nouveau niveau de carburant : " .. turtle.getFuelLevel())
- end
- end
- end
- -- Contrôle nombre de slot poubelle
- function countJunkSlot()
- i = 0
- while (i < 16) do
- i = i + 1
- if turtle.getItemCount(i) == 1 then
- nbJunkSlot = nbJunkSlot + 1
- end
- end
- end
- -- Dechargement dans le coffre
- function dumpInventory()
- i = nbJunkSlot
- while (i < 16) do
- i = i + 1
- turtle.select(i)
- turtle.drop()
- end
- end
- -- Comparer les blocs a miner au dessus
- function compBlocUp()
- i = nbJunkSlot
- while (i < 4) do
- i = i + 1
- turtle.select(i)
- if turtle.compareUp() == false then
- compFalse = compFalse + 1
- elseif turtle.compareUp() == true then
- break
- end
- end
- if compFalse == 4 then
- turtle.digUp()
- else
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement