Модуль:Prototypes/Хранилище/Предмет: различия между версиями

Нет описания правки
Нет описания правки
Строка 1: Строка 1:
-- Загрузка данных
-- Загрузка данных
local itemData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/Item.json/data")
local itemData     = mw.loadData("Модуль:IanComradeBot/prototypes/fills/Item.json/data")
local itemSlotsData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data")
local itemSlotsData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data")
local chemData      = mw.loadData("Модуль:IanComradeBot/prototypes/fills/chem.json/data")


local p = {}
local p = {}
Строка 69: Строка 70:


     local id = content.id or content
     local id = content.id or content
    local name = string.format('{{#invoke:Entity Lookup|getname|%s}}', id)
    local image = string.format('%s.png', id)
      
      
     local amountNumber = 1
     local amountNumber = 1
Строка 93: Строка 92:


     return string.format(
     return string.format(
         '{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Prototypes/Хранилище/Предмет|main|framing|contained|%s}} {{#invoke:Prototypes/Хранилище/Предмет|main|framing|slot|%s}} }}',
         '{{Шаблон:LinkСard/Предмет|%s|%s%s}}',
         image, name, amount, prob, id, id
         id, amount, prob
     )
     )
end
end
Строка 292: Строка 291:
getChemOutput = function(itemData, id)
getChemOutput = function(itemData, id)
     local item = findDataById(itemData, id)
     local item = findDataById(itemData, id)
     if not item or not item.SolutionContainerManager or not item.SolutionContainerManager.solutions then return '' end
     if not item  
      or not item.SolutionContainerManager  
      or not item.SolutionContainerManager.solutions then  
        return ''
    end
 
    local foodSolution = item.SolutionContainerManager.solutions["food"]
    if not foodSolution or not foodSolution.reagents then
        return ''
    end


     local result = ""
     local result = ""
     for _, solution in pairs(item.SolutionContainerManager.solutions) do
     for _, reagent in ipairs(foodSolution.reagents) do
        for _, reagent in ipairs(solution.reagents) do
        result = result .. string.format(
            result = result .. string.format('<li>[[Химия#chem_%s|%s]] (%d ед.)</li>', reagent.ReagentId, reagent.ReagentId, reagent.Quantity)
            '<li>[[Химия#chem_%s|%s]] (%d ед.)</li>',
         end
            reagent.ReagentId, reagent.ReagentId, reagent.Quantity
         )
     end
     end
     return string.format('<ul class="1">%s</ul>', result)
     return string.format('<ul class="1">%s</ul>', result)
end
end
Строка 323: Строка 333:


         if subMode == 'chem' then
         if subMode == 'chem' then
             return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput(itemDataIndex, id) .. '}}')
             return frame:preprocess('{{СollapsibleMenu|color=#3e7c82|' .. getChemOutput(chemData, id) .. '}}')
         elseif subMode == 'contained' then
         elseif subMode == 'contained' then
             return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}')
             return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}')
Строка 338: Строка 348:
         end
         end
     elseif mode == 'chem' then
     elseif mode == 'chem' then
         return frame:preprocess(getChemOutput(itemDataIndex, id))
         return frame:preprocess(getChemOutput(chemData, id))
     elseif mode == 'contained' then
     elseif mode == 'contained' then
         return frame:preprocess(getContainedOutput(itemDataIndex, id))
         return frame:preprocess(getContainedOutput(itemDataIndex, id))