|
|
| (не показана 1 промежуточная версия этого же участника) |
| Строка 1: |
Строка 1: |
| local title = mw.title.new("Участник:IanComradeBot/prototypes/fills/Item.json") | | local loader = require("Module:JsonLoader") |
| local jsonData = title and title:getContent() or ""
| | return loader.getFromTitle("Участник:IanComradeBot/prototypes/fills/Item.json") |
| | |
| local success, data = pcall(mw.text.jsonDecode, jsonData)
| |
| | |
| if not success or type(data) ~= "table" then
| |
| return {}
| |
| end
| |
| | |
| local function normalizeData(item)
| |
| if type(item) ~= "table" then return item end
| |
|
| |
| if item.id and not next(item, "id") then
| |
| for _, fullItem in ipairs(data) do
| |
| if fullItem.id == item.id then
| |
| return fullItem
| |
| end
| |
| end
| |
| end
| |
| | |
| for k, v in pairs(item) do
| |
| item[k] = normalizeData(v)
| |
| end
| |
|
| |
| return item
| |
| end
| |
| | |
| for i, item in ipairs(data) do
| |
| data[i] = normalizeData(item)
| |
| end
| |
| | |
| return data
| |