CCCPaste

3b132b1e1313d

-- me_autocraft.lua
local fileName = "liste.txt"
local meBridge = peripheral.find("meBridge")
if not meBridge then
    error("meBridge non trouvé !")
end

local function autocraft(itemName, amount)
    local tasks = meBridge.craft(itemName, tonumber(amount))
    if tasks then
        print("Craft lancé pour " .. itemName .. " x" .. amount)
    else
        print("Erreur lors du lancement du craft pour " .. itemName)
    end
end

local file = fs.open(fileName, "r")
if not file then
    error("Fichier '" .. fileName .. "' non trouvé")
end

while true do
    local line = file.readLine()
    if not line then break end
    local item, qty = string.match(line, "^([^,]+),(%d+)")
    if item and qty then
        autocraft(item, qty)
    else
        print("Ligne non valide : " .. (line or ""))
    end
end
file.close()
print("Tous les autocrafts ont été lancés !")