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

мНет описания правки
мНет описания правки
Строка 67: Строка 67:
end
end


local function getSpriteState(entry)
local function getSpriteStates(entry)
    local spriteBlock = getInsensitiveKey(entry, "Sprite")
    if spriteBlock and spriteBlock.layers then
        local states = {}
        for _, layer in ipairs(spriteBlock.layers) do
            if not(layer.visible == false) and layer.state then
                table.insert(states, layer.state)
            end
        end
        if #states > 0 then
            return states
        end
    end
     local iconBlock = getInsensitiveKey(entry, "Icon")
     local iconBlock = getInsensitiveKey(entry, "Icon")
     if iconBlock and iconBlock.state then
     if iconBlock and iconBlock.state then
         return iconBlock.state
         return { iconBlock.state }
     end
     end
   
     if spriteBlock and spriteBlock.state then
    local spriteBlock = getInsensitiveKey(entry, "Sprite")
        return { spriteBlock.state }
     if spriteBlock then
        if spriteBlock.state then
            return spriteBlock.state
        elseif spriteBlock.layers then
            for _, layer in pairs(spriteBlock.layers) do
                if layer.state then
                    return layer.state
                end
            end
        end
     end
     end
     return nil
     return nil
end
end
Строка 130: Строка 131:
         return nil
         return nil
     end
     end
    local state = getSpriteState(entry)


     if param == "image" then
     if param == "image" then
        local states = getSpriteStates(entry)
         local stateStr = ""
         local stateStr = ""
         if state then
         if states then
             stateStr = " (state: " .. state .. ")"
             local joined = table.concat(states, ", ")
            local base = "https://github.com/space-syndicate/space-station-14/blob/master/Resources/Textures/" .. spritePath .. "/"
            joined = mw.ustring.gsub(joined, "([%w_]+)", "[" .. base .. "%1.png %1]")
            stateStr = " " .. joined
         end
         end
         return mw.getCurrentFrame():preprocess(
         return mw.getCurrentFrame():preprocess(
Строка 172: Строка 175:
     if action == "repeat" then
     if action == "repeat" then
         return generateRepeatTemplate(spriteData)
         return generateRepeatTemplate(spriteData)
     elseif action == "image" or action == "path" then
     elseif action == "image" then
         local result = {}
         local result = {}
         for _, entry in pairs(spriteData) do
         for _, entry in pairs(spriteData) do