CCCPaste

Tv con dischi

mon = peripheral.wrap("top")
mon.setTextScale(0.5)
term.redirect(mon)

while true do
    -- Controlla se il disco è inserito
    if not disk.hasData("left") then
        mon.clear()
        mon.setCursorPos(1, 1)
        print("INSERIRE UN DISCO")
        sleep(1)
    else
        -- Percorso ai frame sul disco
        local framePath = "/disk/frame"
        if fs.exists(framePath) then
            -- Carica tutti i file immagine presenti
            local files = fs.list(framePath)
            local frames = {}
            for _, file in ipairs(files) do
                local fullPath = framePath .. "/" .. file
                if not fs.isDir(fullPath) then
                    local ok, img = pcall(paintutils.loadImage, fullPath)
                    if ok and img then
                        table.insert(frames, img)
                    end
                end
            end

            -- Se ci sono frame validi, fai l'animazione
            if #frames > 0 then
                while disk.hasData("left") do
                    for _, frame in ipairs(frames) do
                        paintutils.drawImage(frame, 1, 1)
                        sleep(0.2)
                    end
                end
            else
                mon.clear()
                mon.setCursorPos(1, 1)
                print("NESSUN FRAME TROVATO SU /disk/frame")
                sleep(2)
            end
        else
            mon.clear()
            mon.setCursorPos(1, 1)
            print("NESSUNA CARTELLA /frame SUL DISCO")
            sleep(2)
        end
    end
end