Модуль:Песочница/Pok: различия между версиями

Нет описания правки
Метка: ручная отмена
мНет описания правки
Строка 1: Строка 1:
local p = {}
local p = {}


-- Загрузка данных
local function loadResearchData()
local function loadData(filePath)
     local jsonContent = mw.title.new("User:IanComradeBot/Песочница.json"):getContent()
     local page = mw.title.new(filePath)
     if not jsonContent or jsonContent == "" then
     local content = page and page:getContent()
        error("Не удалось загрузить содержимое JSON-файла.")
     return content and mw.text.jsonDecode(content) or nil
     end
    local success, data = pcall(mw.text.jsonDecode, jsonContent)
    if not success then
        error("Ошибка декодирования JSON: " .. tostring(data))
    end
    return data
end
end


Строка 67: Строка 72:
     })
     })


     local dataCache = loadData("User:IanComradeBot/Песочница.json")
     local dataCache = loadResearchData()
    if not data or type(data) ~= 'table' then
        return 'Ошибка: Невозможно загрузить данные из JSON.'
    end
   
     local discipline = frame.args[1] or ""
     local discipline = frame.args[1] or ""