CCCPaste

ed58ff83db053

local configPath = "config"

-- =========================
-- FUNZIONI DI SUPPORTO
-- =========================
local function loadConfig()
    if not fs.exists(configPath) then return nil end
    local f = fs.open(configPath, "r")
    local data = f.readAll()
    f.close()
    local func = loadstring(data)
    if func then return func() else error("Errore nel config") end
end

local function saveConfig(cfg)
    local f = fs.open(configPath, "w")
    f.write("return " .. textutils.serialize(cfg))
    f.close()
end

local function listReactors(cfg)
    print("\nLista reattori:")
    for i, r in ipairs(cfg.reactors) do
        print(string.format(" [%d] Nome: %s | ID: %d | Colore: %s", i, r.name, r.id, r.color))
    end
end

local function getValidColors()
    local t = {}
    for k, v in pairs(colors) do
        t[k] = v
    end