Модуль:Prototypes/Хранилище/Предмет: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 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 amountNumber = 1 | local amountNumber = 1 | ||
| Строка 93: | Строка 92: | ||
return string.format( | return string.format( | ||
'{{LinkСard| | '{{Шаблон:LinkСard/Предмет|%s|%s%s}}', | ||
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 _, reagent in ipairs(foodSolution.reagents) do | |||
result = result .. string.format( | |||
'<li>[[Химия#chem_%s|%s]] (%d ед.)</li>', | |||
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( | 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( | 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)) | ||