Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local BedrockDetection = false
- local Charcoalslot = 1
- local Charcoalmini = 5
- local Fuellvlmini = 5
- local Endercharcoalslot = 15
- local Enderchestslot = 16
- local premierminerai = 2
- local dernierminerai = 14
- local x = 1
- local y = 1
- local z = 1
- impair = true
- tourner = true
- -- Fonctions : Début
- -- Fonction Charcoalfuel : Detecte s'il faut se réapprovisionner en charcoal
- function Charcoalrefuel()
- local Fuellvl = turtle.getFuelLevel()
- if Fuellvl < Fuellvlmini then
- turtle.select(Charcoalslot)
- if turtle.getItemCount(Charcoalslot) < Charcoalmini then
- Charcoalreload()
- end
- turtle.reFuel(1)
- else
- return true
- end
- end
- function Charcoalreload() -- Fonction de rechargement en charcoal
- if turtle.detectUp() then
- turtle.digUp()
- os.sleep(0.5)
- end
- if turtle.getItemCount(dernierminerai) > 62 then
- VidageInventaire()
- end
- turtle.select(Endercharcoalslot)
- turtle.placeUp()
- turtle.select(Charcoalslot)
- turtle.suckUp()
- turtle.select(Endercharcoalslot)
- turtle.digUp()
- end
- function VidageInventaire() -- Fonction de vidage des minerais creusés dans l'enderchest dédié à ça
- local slot
- if turtle.detectUp() then
- turtle.digUp()
- os.sleep(0.5)
- end
- turtle.select(Enderchestslot)
- turtle.placeUp()
- for slot=premierminerai,dernierminerai do
- turtle.select(slot)
- while turtle.getItemCount(slot) > 0 do
- turtle.dropUp(turtle.getItemCount(slot))
- end
- end
- turtle.select(Enderchestslot)
- turtle.digUp()
- end
- function Remplissageslot()
- if turtle.getItemCount(dernierminerai) > 0 then
- VidageInventaire()
- else
- return true
- end
- end
- function move(direction)
- while true do
- if direction == "forward" then
- if turtle.detect() then
- turtle.dig()
- else
- if turtle.forward() then
- return true
- else
- turtle.attack()
- end
- end
- elseif direction == "up" then
- if turtle.detectUp() then
- turtle.digUp()
- os.sleep(0.5)
- else
- if turtle.up() then
- return true
- else
- turtle.attackUp()
- end
- end
- end
- end
- while true do
- if direction == "down" then
- if turtle.detectDown() then
- turtle.digDown()
- os.sleep(0.5)
- else
- if turtle.down() then
- return true
- else
- turtle.attackDown()
- end
- end
- end
- end
- end
- function RetourBedrock() -- Retour vers le point le point de départ si la turtle a atteint la bedrock
- for i=z-1,1,-1 do
- move("up")
- end
- if impair then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- for i=Quarrydim,1,-1 do
- move("forward")
- end
- end
- -- Fonctions : Fin
- -- Programme : Début
- term.clear()
- term.setCursorPos(1,1)
- print("Programme de quarry avec mining turtle - Par Fiixii52")
- while true do
- shell.run('clear') -- add bimgo
- term.setCursorPos(1,3)
- print("Mettez du coal / charcoal dans le premier slot de la turtle")
- io.read()
- if turtle.getItemCount(Charcoalslot) > 0 then
- break
- else
- term.setCursorPos(1,5)
- print("Coal / Charcoal non détecté. Veuillez recommencer")
- io.read()
- end
- end
- while true do
- shell.run('clear') -- add bimgo
- term.setCursorPos(1,3)
- print("Mettez l'enderchest dédié au charcoal dans le slot 15 de la turtle")
- io.read()
- if turtle.getItemCount(Endercharcoalslot) > 0 then
- break
- else
- term.setCursorPos(1,5)
- print("Enderchest au charcoal non détecté. Veuillez recommencer")
- io.read()
- end
- end
- while true do
- shell.run('clear') -- add bimgo
- term.setCursorPos(1,3)
- print("Mettez l'enderchest dédié aux minerais dans le dernier slot de la turtle")
- io.read()
- if turtle.getItemCount(Enderchestslot) > 0 then
- break
- else
- term.setCursorPos(1,5)
- print("Enderchest au minerais non détecté. Veuillez recommencer")
- io.read()
- end
- end
- while true do
- shell.run('clear') -- add bimgo
- term.setCursorPos(1,3)
- print("Indiquez la longueur de la quarry : ")
- Quarrydim = io.read()
- Quarrydim = tonumber(Quarrydim)
- if Quarrydim == nil then
- print("Erreur de frappe. Veuillez recommencer")
- io.read()
- else
- break
- end
- end
- while true do
- shell.run('clear') -- add bimgo
- term.clear()
- print("Charcoal du slot 1 détecté")
- print("Enderchest dédié au coal / charcoal détecté")
- print("Enderchest dédié aux minerais détecté")
- print("Dimension de la quarry : "..Quarrydim.." x "..Quarrydim.."")
- print("Confirmer le lancement de la turtle ?")
- print("Appuyez sur O pour confirmer le lancement, N pour l'annuler")
- param1 = read()
- print("touche pressee "..param1)
- sleep(10)
- if param1 == "o" then
- break
- elseif param1 == "n" then
- os.reboot()
- end
- end
- while true do -- Programme : Boucle principale
- while turtle.digUp() do
- os.sleep(0.5)
- end
- Remplissageslot()
- repeat -- Excavate fonction avec 3 repeat emboîtés (Merci lucasgood :D)
- repeat
- repeat
- x = x + 1
- move("forward")
- Charcoalrefuel()
- Remplissageslot()
- until x == Quarrydim
- turtle.turnRight()
- move("forward")
- turtle.turnRight()
- x = 1
- repeat
- x = x + 1
- move("forward")
- Charcoalrefuel()
- Remplissageslot()
- until x == Quarrydim
- turtle.turnLeft()
- move("forward")
- turtle.turnLeft()
- x = 1
- y = y + 2
- until y == Quarrydim
- for i=1,2 do
- move("down")
- os.sleep(0.5)
- end
- x = 1
- y = 1
- if not move("down") then -- Si la turtle ne peut pas miner en bas, c'est la bedrock
- BedrockDetection = true
- RetourBedrock()
- else
- return true
- end
- z = z + 1
- until z == Quarrydim
- end
Advertisement
Add Comment
Please, Sign In to add comment