Модуль:Entity Sprite: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 29: | Строка 29: | ||
for _, entry in ipairs(data) do | for _, entry in ipairs(data) do | ||
if entry.Sprite and entry.EntityStorageVisuals then | local found = false | ||
for key, group in pairs(spriteGroups) do | |||
if deepEqual(entry.Sprite, group[1].Sprite) and deepEqual(entry.EntityStorageVisuals, group[1].EntityStorageVisuals) then | |||
table.insert(spriteGroups | table.insert(group, entry) | ||
found = true | |||
break | |||
end | |||
end | |||
if not found then | |||
table.insert(spriteGroups, {entry}) | |||
end | end | ||
end | end | ||
local result = {} | local result = {} | ||
for _, | for _, group in pairs(spriteGroups) do | ||
if # | if #group > 1 then | ||
local idLinks = {} | local idLinks = {} | ||
for _, | for _, entry in ipairs(group) do | ||
table.insert(idLinks, "[[:Файл:" .. id .. ".png]]") | table.insert(idLinks, "[[:Файл:" .. entry.id .. ".png]]") | ||
end | end | ||
local firstId = | local firstId = group[1].id | ||
table.insert(result, mw.getCurrentFrame():preprocess("{{Entity Sprite/Repeat|" .. table.concat(idLinks, " ") .. "|" .. firstId .. "}}")) | table.insert(result, mw.getCurrentFrame():preprocess("{{Entity Sprite/Repeat|" .. table.concat(idLinks, " ") .. "|" .. firstId .. "}}")) | ||
end | end | ||