Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 68: | Строка 68: | ||
local function getSpriteStates(entry) | local function getSpriteStates(entry) | ||
local spriteBlock = | local result = {} | ||
local spriteBlock = findFieldInsensitive(entry, "Sprite") | |||
if spriteBlock and spriteBlock.layers then | if spriteBlock and spriteBlock.layers then | ||
for _, layer in ipairs(spriteBlock.layers) do | for _, layer in ipairs(spriteBlock.layers) do | ||
if | if layer.visible == false then | ||
table.insert( | elseif layer.state and layer.sprite then | ||
table.insert(result, { state = layer.state, sprite = layer.sprite }) | |||
elseif layer.state then | |||
table.insert(result, { state = layer.state, sprite = getSpritePath(entry) }) | |||
end | end | ||
end | end | ||
end | end | ||
local iconBlock = | if #result > 0 then | ||
return result | |||
end | |||
local iconBlock = findFieldInsensitive(entry, "Icon") | |||
if iconBlock and iconBlock.state then | if iconBlock and iconBlock.state then | ||
return { iconBlock.state } | return { { state = iconBlock.state, sprite = getSpritePath(entry) } } | ||
end | end | ||
if spriteBlock and spriteBlock.state then | if spriteBlock and spriteBlock.state then | ||
return { spriteBlock.state } | return { { state = spriteBlock.state, sprite = getSpritePath(entry) } } | ||
end | end | ||
return nil | return nil | ||
end | end | ||