Модуль:Предмет: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 2: | Строка 2: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
-- | -- Функция-формировщик для возвращения строки #invoke | ||
local function | local function invoke(module, method, sub, extra, id) | ||
return string.format("{{#invoke:%s|%s|%s|%s|%s}}", | |||
module, method, sub or "", extra or "", id or "") | |||
end | end | ||
| Строка 33: | Строка 26: | ||
end | end | ||
local id | local id = args[1] or "" | ||
local size | local size = args.size or "32px" | ||
local prefix= args[2] or "" | local prefix = args[2] or "" | ||
local repoM = argsRaw.repository ~= nil | local repoM = argsRaw.repository ~= nil | ||
local wrapM = argsRaw.wrapper ~= nil | local wrapM = argsRaw.wrapper ~= nil | ||
local vert | local vert = argsRaw.vertical ~= nil | ||
-- Имя и метка | -- Имя и метка | ||
local rawLabel = argsRaw.label or argsRaw.l | local rawLabel = argsRaw.label or argsRaw.l | ||
local nameStr = | local nameStr = invoke("Entity Lookup", "getname", id) | ||
local label = rawLabel == nil and nameStr or (rawLabel == "" and "" or rawLabel) | local label = rawLabel == nil and nameStr or (rawLabel == "" and "" or rawLabel) | ||
local rawLink = argsRaw.link | local rawLink = argsRaw.link | ||
| Строка 66: | Строка 57: | ||
end | end | ||
-- Репозиторий | -- Репозиторий | ||
local repoStr = "" | local repoStr = "" | ||
if repoM then | if repoM then | ||
repoStr = table.concat({ | repoStr = table.concat({ | ||
invoke("Prototypes/Хранилище/Предмет", "main", "framing|contained", id), | |||
invoke("Prototypes/Хранилище/Предмет", "main", "framing|slot", id), | |||
string.format( | string.format( | ||
"{{СollapsibleMenu|color=#3e7c82|%s}}", | "{{СollapsibleMenu|color=#3e7c82|%s}}", | ||
invoke("Prototypes/Хранилище/Предмет", "main", "chem", id) | |||
) | ) | ||
}, " ") | }, " ") | ||
| Строка 89: | Строка 80: | ||
) | ) | ||
) | ) | ||
table.insert(parts, | table.insert(parts, invoke("Prototypes/Хранилище/Предмет", "main", "framing|stack", id)) | ||
table.insert(parts, prefix) | table.insert(parts, prefix) | ||
else | else | ||
| Строка 96: | Строка 87: | ||
) | ) | ||
table.insert(parts, labelOut) | table.insert(parts, labelOut) | ||
table.insert(parts, | table.insert(parts, invoke("Prototypes/Хранилище/Предмет", "main", "framing|stack", id)) | ||
table.insert(parts, prefix) | table.insert(parts, prefix) | ||
end | end | ||
| Строка 108: | Строка 99: | ||
"{{LinkCard|name=%s %s %s|pin=%s|image-full=%s|pixel=%s|link=%s%s}}", | "{{LinkCard|name=%s %s %s|pin=%s|image-full=%s|pixel=%s|link=%s%s}}", | ||
labelOut, | labelOut, | ||
invoke("Prototypes/Хранилище/Предмет", "main", "framing|stack", id), | |||
prefix, | prefix, | ||
repoStr, | repoStr, | ||