Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
||
| Строка 2: | Строка 2: | ||
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 p = {} | local p = {} | ||
| Строка 85: | Строка 84: | ||
return string.format( | return string.format( | ||
'{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Песочница/Pok|main|framing|contained|%s}} {{#invoke:Песочница/Pok|main|framing|slot | '{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Песочница/Pok|main|framing|contained|%s}} {{#invoke:Песочница/Pok|main|framing|slot|%s}} }}', | ||
image, name, amount, prob | image, name, amount, prob, id, id | ||
) | ) | ||
end | end | ||
| Строка 284: | Строка 283: | ||
getChemOutput = function(itemData, id) | getChemOutput = function(itemData, id) | ||
local item = findDataById(itemData, id) | local item = findDataById(itemData, id) | ||
if not item | if not item or not item.SolutionContainerManager or not item.SolutionContainerManager.solutions then return '' end | ||
local result = "" | local result = "" | ||
for _, reagent in ipairs( | for _, solution in pairs(item.SolutionContainerManager.solutions) do | ||
for _, reagent in ipairs(solution.reagents) do | |||
result = result .. string.format('<li>[[Химия#chem_%s|%s]] (%d ед.)</li>', reagent.ReagentId, reagent.ReagentId, reagent.Quantity) | |||
end | |||
end | end | ||
return string.format('<ul class="1">%s</ul>', result) | return string.format('<ul class="1">%s</ul>', result) | ||
end | end | ||
| Строка 326: | Строка 314: | ||
if subMode == 'chem' then | if subMode == 'chem' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput( | return frame:preprocess('{{СollapsibleMenu|' .. getChemOutput(itemDataIndex, id) .. '}}') | ||
elseif subMode == 'contained' then | elseif subMode == 'contained' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | ||
| Строка 341: | Строка 329: | ||
end | end | ||
elseif mode == 'chem' then | elseif mode == 'chem' then | ||
return frame:preprocess(getChemOutput( | return frame:preprocess(getChemOutput(itemDataIndex, id)) | ||
elseif mode == 'contained' then | elseif mode == 'contained' then | ||
return frame:preprocess(getContainedOutput(itemDataIndex, id)) | return frame:preprocess(getContainedOutput(itemDataIndex, id)) | ||