Модуль: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 p = {} | local p = {} | ||
| Строка 32: | Строка 31: | ||
return result | return result | ||
end | end | ||
-- Локальные функции | -- Локальные функции | ||
| Строка 64: | Строка 47: | ||
-- Форматирование содержимого | -- Форматирование содержимого | ||
formatContent = function(content) | formatContent = function(content) | ||
if | if not content.id then | ||
return "Ошибка: отсутствует id у элемента." | return "Ошибка: отсутствует id у элемента." | ||
end | end | ||
local name = string.format('{{#invoke:Entity Lookup|getname|%s}}', content.id) | |||
local image = string.format('%s.png', content.id) | |||
local name = string.format('{{#invoke:Entity Lookup|getname|%s}}', id) | local amount = (content.amount and content.amount ~= 1) and string.format(" [%d]", content.amount) or "" | ||
local image = string.format('%s.png', id) | |||
local prob = "" | local prob = "" | ||
| Строка 84: | Строка 65: | ||
return string.format( | return string.format( | ||
'{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Prototypes/Хранилище/Предмет|main|framing|contained | '{{LinkСard|SideStyle=1|background-color=#cbcbff0a|image=%s|name=%s%s%s {{#invoke:Prototypes/Хранилище/Предмет|main|framing|contained|%s}} }}', | ||
image, name, amount, prob, | image, name, amount, prob, content.id | ||
) | ) | ||
end | end | ||
| Строка 317: | Строка 298: | ||
elseif subMode == 'contained' then | elseif subMode == 'contained' then | ||
return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | return frame:preprocess('{{СollapsibleMenu|' .. getContainedOutput(itemDataIndex, id) .. '}}') | ||
else | else | ||
return 'Неизвестный подрежим для framing: ' .. subMode | return 'Неизвестный подрежим для framing: ' .. subMode | ||
| Строка 332: | Строка 305: | ||
elseif mode == 'contained' then | elseif mode == 'contained' then | ||
return frame:preprocess(getContainedOutput(itemDataIndex, id)) | return frame:preprocess(getContainedOutput(itemDataIndex, id)) | ||
elseif mode == 'rolls' then | elseif mode == 'rolls' then | ||
local entity = findDataById(itemDataIndex, id) | local entity = findDataById(itemDataIndex, id) | ||