Модуль:Prototypes/Хранилище/Предмет: различия между версиями
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 itemStackData = mw.loadData("Модуль:IanComradeBot/prototypes/ItemSlots.json/data") | |||
local chemData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/chem.json/data") | local chemData = mw.loadData("Модуль:IanComradeBot/prototypes/fills/chem.json/data") | ||
local chemTranslateData = mw.loadData("Модуль:IanComradeBot/chem prototypes.json/data") | local chemTranslateData = mw.loadData("Модуль:IanComradeBot/chem prototypes.json/data") | ||
| Строка 346: | Строка 347: | ||
return result ~= "" and string.format('<ul class="1">%s</ul>', result) or '' | return result ~= "" and string.format('<ul class="1">%s</ul>', result) or '' | ||
end | |||
-- Функция поиска count в itemStackData | |||
local function getStackCount(id) | |||
local item = findDataById(itemStackData, id) | |||
if item and item.Stack and item.Stack.count then | |||
return item.Stack.count | |||
end | |||
return nil | |||
end | end | ||
| Строка 371: | Строка 381: | ||
elseif subMode == 'contained' then | elseif subMode == 'contained' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | ||
elseif subMode == "slot" then | |||
local itemDataEntry = findDataById(itemSlotsData, id) | |||
if not itemDataEntry then return "" end | |||
local startingItem = getFirstStartingItem(itemDataEntry) | |||
if not startingItem then return "" end | |||
return frame:preprocess('{{СollapsibleMenu|color=#71702a|' .. formatContent(startingItem) .. '}}') | |||
elseif subMode == "stack" then | |||
local count = getStackCount(id) | |||
return count and '(' .. count .. ')' or "" | |||
else | else | ||
return 'Неизвестный подрежим для framing: ' .. subMode | return 'Неизвестный подрежим для framing: ' .. subMode | ||
end | end | ||
elseif mode == 'stack' then | |||
local count = getStackCount(id) | |||
return count or "" | |||
elseif mode == 'chem' then | elseif mode == 'chem' then | ||
return getChemOutput(chemData, id) | return getChemOutput(chemData, id) | ||
elseif mode == 'contained' then | elseif mode == 'contained' then | ||
return frame:preprocess(getContainedOutput(itemDataIndex, id)) | return frame:preprocess(getContainedOutput(itemDataIndex, id)) | ||
elseif mode == "slot" then | |||
local itemDataEntry = findDataById(itemSlotsData, id) | |||
if not itemDataEntry then return "" end | |||
local startingItem = getFirstStartingItem(itemDataEntry) | |||
if not startingItem then return "" end | |||
return frame:preprocess(formatContent(startingItem)) | |||
elseif mode == 'rolls' then | elseif mode == 'rolls' then | ||
local entity = findDataById(itemDataIndex, id) | local entity = findDataById(itemDataIndex, id) | ||
if not entity then return 'ID не найден в данных.' end | if not entity then return 'ID не найден в данных.' end | ||
if entity.EntityTableContainerFill then | if entity.EntityTableContainerFill then | ||
local containers = entity.EntityTableContainerFill.containers | local containers = entity.EntityTableContainerFill.containers | ||
| Строка 404: | Строка 415: | ||
end | end | ||
end | end | ||
return '' | return '' | ||
else | else | ||