Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
local p = {} | local p = {} | ||
local JsonPaths = require('Module:JsonPaths') | local JsonPaths = require('Module:JsonPaths') | ||
local function buildEntryKey(entry) | |||
local parts = {} | |||
if entry.sprite then | |||
table.insert(parts, "sprite=" .. normalizeSpritePath(entry.sprite)) | |||
end | |||
if entry.layers and type(entry.layers) == "table" then | |||
local layers = {} | |||
for _, layer in ipairs(entry.layers) do | |||
local layerParts = {} | |||
for k, v in pairs(layer) do | |||
layerParts[#layerParts+1] = k .. "=" .. tostring(v) | |||
end | |||
table.sort(layerParts) | |||
table.insert(layers, table.concat(layerParts, ",")) | |||
end | |||
table.sort(layers) | |||
table.insert(parts, "layers=" .. table.concat(layers, "|")) | |||
end | |||
return table.concat(parts, ";") | |||
end | |||
local function normalizeSpritePath(path) | local function normalizeSpritePath(path) | ||
| Строка 146: | Строка 174: | ||
for id, entry in pairs(data) do | for id, entry in pairs(data) do | ||
local | local key = buildEntryKey(entry) | ||
spriteGroups[key] = spriteGroups[key] or {} | |||
table.insert(spriteGroups[key], { id = id, entry = entry }) | |||
end | end | ||
| Строка 171: | Строка 186: | ||
local idLinks = {} | local idLinks = {} | ||
for _, obj in | for _, obj in ipairs(group) do | ||
local id = obj.id | local id = obj.id | ||
local prefix = getPrefix(id, project) | local prefix = getPrefix(id, project) | ||