Модуль:Entity Sprite/all: различия между версиями
Pok (обсуждение | вклад) мНет описания правки |
Pok (обсуждение | вклад) мНет описания правки |
||
| Строка 83: | Строка 83: | ||
local iconBlock = findFieldInsensitive(entry, "Icon") | local iconBlock = findFieldInsensitive(entry, "Icon") | ||
local spriteBlock = findFieldInsensitive(entry, "Sprite") | |||
if iconBlock and iconBlock.state then | if iconBlock and iconBlock.state then | ||
addState(iconBlock.state, | addState(iconBlock.state, iconBlock.sprite or spritePath) | ||
else | else | ||
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 | ||
local s = layer.sprite or spritePath | local stateName = layer.state or (iconBlock and iconBlock.state) or "icon" | ||
addState( | local s = layer.sprite or (iconBlock and iconBlock.sprite) or spritePath | ||
addState(stateName, s) | |||
break | break | ||
end | end | ||
end | end | ||
elseif spriteBlock and spriteBlock.state then | elseif spriteBlock and spriteBlock.state then | ||
addState(spriteBlock.state, | addState(spriteBlock.state, spriteBlock.sprite or spritePath) | ||
end | end | ||
end | end | ||
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 | ||
local alreadyAdded = false | local alreadyAdded = false | ||
for _, r in ipairs(result) do | for _, r in ipairs(result) do | ||
if r.state == | local layerState = layer.state or "icon" | ||
if r.state == layerState then | |||
alreadyAdded = true | alreadyAdded = true | ||
break | break | ||
| Строка 111: | Строка 113: | ||
end | end | ||
if not alreadyAdded | if not alreadyAdded and layer.visible ~= false then | ||
local s = layer.sprite or spritePath | local stateName = layer.state or "icon" | ||
addState( | local s = layer.sprite or (iconBlock and iconBlock.sprite) or spritePath | ||
if s then | |||
addState(stateName, s) | |||
end | |||
end | end | ||
end | end | ||
end | |||
if #result == 0 and (iconBlock and (iconBlock.sprite or iconBlock.state) or spritePath) then | |||
local s = (iconBlock and iconBlock.sprite) or spritePath | |||
addState("icon", s) | |||
end | end | ||