Модуль:Песочница/Pok: различия между версиями
Pok (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 64: | Строка 64: | ||
-- Форматирование содержимого | -- Форматирование содержимого | ||
formatContent = function(content) | formatContent = function(content) | ||
if type(content) == " | -- Если content передаётся как строка, трактуем её как ID | ||
if type(content) == "string" then | |||
content = { id = content } | |||
end | |||
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 image = string.format('%s.png', id) | |||
local amount = (content.amount and content.amount ~= 1) and string.format(" [%d]", content.amount) or "" | local amount = (content.amount and content.amount ~= 1) and string.format(" [%d]", content.amount) or "" | ||
local prob = "" | local prob = "" | ||
| Строка 85: | Строка 88: | ||
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|%s}} }}', | '{{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, id, id | image, name, amount, prob, content.id, content.id | ||
) | ) | ||
end | end | ||