Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 74: | Строка 74: | ||
local function getSpriteStates(entry) | local function getSpriteStates(entry) | ||
local | local result = {} | ||
local function addState(state, sprite) | |||
table.insert(result, { state = state, sprite = sprite }) | |||
end | end | ||
local | local spritePath = getSpritePath(entry) | ||
local | local iconBlock = findFieldInsensitive(entry, "Icon") | ||
for _, layer in ipairs(spriteBlock.layers) do | if iconBlock and iconBlock.state then | ||
addState(iconBlock.state, getSpritePath(entry)) | |||
else | |||
local spriteBlock = findFieldInsensitive(entry, "Sprite") | |||
if spriteBlock and spriteBlock.layers then | |||
for _, layer in ipairs(spriteBlock.layers) do | |||
if layer.state and layer.visible ~= false then | |||
local s = layer.sprite or spritePath | |||
addState(layer.state, s) | |||
break | |||
end | |||
end | |||
elseif spriteBlock and spriteBlock.state then | |||
addState(spriteBlock.state, getSpritePath(entry)) | |||
end | end | ||
end | end | ||
local spriteBlock = findFieldInsensitive(entry, "Sprite") | |||
if spriteBlock and spriteBlock.layers then | |||
for _, layer in ipairs(spriteBlock.layers) do | |||
local alreadyAdded = false | |||
local | for _, r in ipairs(result) do | ||
if | if r.state == layer.state then | ||
alreadyAdded = true | |||
break | |||
end | |||
end | |||
if not alreadyAdded and layer.state and isStateFirstKey(layer) and layer.visible ~= false then | |||
local s = layer.sprite or spritePath | |||
addState(layer.state, s) | |||
end | end | ||
end | end | ||