Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle minière intelligente : mine, se refuel, range
- local depth = 100 -- profondeur de minage
- local chestSlot = 16 -- Slot où ranger les objets à déposer
- local fuelSlot = 1 -- Slot de carburant
- -- Vérifie si un bloc est un minerai
- function isOre(name)
- return string.find(name, "ore") or string.find(name, "Ore")
- end
- -- Creuse autour si minerai détecté
- function checkAround()
- local directions = {
- {func=turtle.inspectUp, dig=turtle.digUp, move=turtle.up, down=turtle.down},
- {func=turtle.inspectDown, dig=turtle.digDown, move=turtle.down, down=turtle.up},
- {func=turtle.inspect, dig=turtle.dig, move=turtle.forward, down=turtle.back}
- }
- for i = 1, 4 do
- local success, data = turtle.inspect()
- if success and data.name and isOre(data.name) then
- turtle.dig()
- turtle.forward()
- checkAround()
- turtle.back()
- end
- turtle.turnRight()
- end
- for _, dir in ipairs(directions) do
- local success, data = dir.func()
- if success and data.name and isOre(data.name) then
- dir.dig()
- dir.move()
- checkAround()
- dir.down()
- end
- end
- end
- -- Vérifie et fait le refuel si besoin
- function checkFuel()
- if turtle.getFuelLevel() < 50 then
- turtle.select(fuelSlot)
- if not turtle.refuel(1) then
- print("Pas assez de carburant !")
- return false
- end
- end
- return true
- end
- -- Dépose les ressources dans le coffre
- function unload()
- turtle.turnLeft()
- turtle.turnLeft()
- for slot = 2, 15 do
- turtle.select(slot)
- turtle.drop()
- end
- turtle.select(fuelSlot)
- turtle.turnRight()
- turtle.turnRight()
- end
- -- Boucle principale
- for i = 1, depth do
- if not checkFuel() then break end
- turtle.dig()
- turtle.forward()
- checkAround()
- end
- -- Retour à la base
- for i = 1, depth do
- turtle.back()
- end
- unload()
Advertisement
Add Comment
Please, Sign In to add comment