CCCPaste

aa mater

-- Configuration
local threshold = 0.20   -- 20%

while true do
    local cable = peripheral.wrap("top")
    if cable then
        local fill = cable.getFilledPercentage()

        if fill then
            print("Cable: " .. (fill * 100) .. "% full")

            if fill > threshold then
                redstone.setOutput("bottom", true)
            else
                redstone.setOutput("bottom", false)
            end
        else
            print("Erreur : périphérique sans getFilledPercentage()")
        end
    else
        print("Aucun périphérique détecté en haut")
    end

    sleep(1) -- évite de spam la boucle
end