Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function rechargeTurtle()
- local carburants = {
- ["minecraft:coal"] = true,
- ["minecraft:charcoal"] = true,
- ["thermalfoundation:material"] = true -- exemple: coal coke (à adapter selon damage)
- }
- local fuelAvant = turtle.getFuelLevel()
- local carburantTrouve = false
- for slot = 1, 16 do
- turtle.select(slot)
- local item = turtle.getItemDetail()
- if item then
- -- Vérifie si l'item est un carburant utilisable
- if turtle.refuel(0) then
- turtle.refuel()
- print("Rechargement avec : " .. item.name)
- carburantTrouve = true
- end
- end
- end
- local fuelApres = turtle.getFuelLevel()
- turtle.select(1) -- revenir au slot 1
- if carburantTrouve then
- print("Carburant avant : " .. fuelAvant)
- print("Carburant après : " .. fuelApres)
- print("Quantité rechargée : " .. (fuelApres - fuelAvant))
- else
- print("Aucun carburant valide trouvé dans l'inventaire.")
- end
- end
- -- Exécution
- rechargeTurtle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement