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

мНет описания правки
мНет описания правки
Строка 21: Строка 21:
-- Функция получения пути спрайта
-- Функция получения пути спрайта
local function getSpritePath(entry)
local function getSpritePath(entry)
     local spriteBlock = findFieldInsensitive(entry, "Sprite") or findFieldInsensitive(entry, "Icon")
     local spriteBlock = findFieldInsensitive(entry, "Sprite")
     if spriteBlock then
                    or findFieldInsensitive(entry, "Icon")
         if spriteBlock.sprite then
     if not spriteBlock then
            return spriteBlock.sprite
         return nil
        elseif spriteBlock.layers then
    end
            for _, layer in pairs(spriteBlock.layers) do
 
                if layer.sprite then
    if type(spriteBlock) == "string" then
                    return layer.sprite
        return spriteBlock
                end
    end
 
    if spriteBlock.sprite then
        return spriteBlock.sprite
    elseif spriteBlock.layers then
        for _, layer in pairs(spriteBlock.layers) do
            if layer.sprite then
                return layer.sprite
             end
             end
         end
         end
     end
     end
     return nil
     return nil
end
end