Module:Abilities/icon: Difference between revisions

mNo edit summary
mNo edit summary
Line 56: Line 56:
}
}


-- get scaling icon attributes associated with a specified scale type
function getScalarIcon(scaleType)
function getScalarIcon(scaleType, attribute)
return SCALING_ICON_MAP[scaleType]
local scalingIcon = SCALING_ICON_MAP[scaleType]
 
    if scalingIcon then
        return scalingIcon[attribute] or "Missing scaling type in Module:Abilities/icon"
    end
 
    return ""
end
end


function p._getScalarIcon(scaleType, attribute)
return getScalarIcon(scaleType, attribute)
end


function p.getScalarIcon(frame)
-- get scaling icon attribute associated with a specified scale type
function p.getScalarIconAttr(frame)
     local args = frame.args
     local args = frame.args


Line 77: Line 68:
     local attribute = args[2]
     local attribute = args[2]
return getScalarIcon(scaleType, attribute)
local icon = getScalarIcon(scaleType, attribute)
return icon[attribute] or 'Missing scaling attribute ' .. attribute .. ' for type ' .. scaleType
end
end


-- get scaling icon wikitext file associated with a specified scale type
function p.getScalarIconFile(frame)
function p.getScalarIconFile(frame)
     local args = frame.args
     local args = frame.args
Line 85: Line 78:


local icon = getScalarIcon(scaleType)
local icon = getScalarIcon(scaleType)
     if not icon then
     if not icon then
         return string.format('[[Tooltip|?|Missing scaling type icon "%s" in Module:Abilities/icon]]', scaleType)
         return string.format('[[Tooltip|?|Missing scaling type icon "%s" in Module:Abilities/icon]]', scaleType)
Line 94: Line 86:
end
end
     return '<span class="ac-scaling--' .. icon.class .. '">'
     return string.format(
        .. '[[' .. icon.icon .. '|link=' .. icon.link .. '|' .. icon.size .. ']]'
        '<span class="ac-scaling--%s">[[%s|link=%s|%s]]</span>',
        .. '</span>'
        icon.class,
        icon.icon,
        icon.link,
        icon.size
    )
end
end


return p
return p