Модуль:IanComradeBot/prototypes/fills/Item.json/data: различия между версиями

Материал из Space Station 14 Вики
мНет описания правки
м Update via atematic bot
 
(не показана 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

Текущая версия от 11:30, 17 июля 2025

Для документации этого модуля может быть создана страница Модуль:IanComradeBot/prototypes/fills/Item.json/data/doc

local loader = require("Module:JsonLoader")
return loader.getFromTitle("Участник:IanComradeBot/prototypes/fills/Item.json")