Модуль:Entity Sprite/all: различия между версиями

мНет описания правки
мНет описания правки
Строка 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, getSpritePath(entry))
         addState(iconBlock.state, iconBlock.sprite or spritePath)
     else
     else
        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 layer.state and layer.visible ~= false then
                 if layer.visible ~= false then
                     local s = layer.sprite or spritePath
                    local stateName = layer.state or (iconBlock and iconBlock.state) or "icon"
                     addState(layer.state, s)
                     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, getSpritePath(entry))
             addState(spriteBlock.state, spriteBlock.sprite or spritePath)
         end
         end
     end
     end


    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
             local alreadyAdded = false
             local alreadyAdded = false
             for _, r in ipairs(result) do
             for _, r in ipairs(result) do
                 if r.state == layer.state then
                local layerState = layer.state or "icon"
                 if r.state == layerState then
                     alreadyAdded = true
                     alreadyAdded = true
                     break
                     break
Строка 111: Строка 113:
             end
             end


             if not alreadyAdded and layer.state and isStateFirstKey(layer) and layer.visible ~= false then
             if not alreadyAdded and layer.visible ~= false then
                 local s = layer.sprite or spritePath
                local stateName = layer.state or "icon"
                 addState(layer.state, s)
                 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