Module:Icons: Difference between revisions

Icon: Resolve declaration with same name as global function ('type'), extend image overrides to optionally override type also
(Amend extension overrides for names containing apostrophes)
(Icon: Resolve declaration with same name as global function ('type'), extend image overrides to optionally override type also)
Line 156: Line 156:
   ['slayer'] = 'combatArea',
   ['slayer'] = 'combatArea',
}
}
--When calling for an icon for Key, replace with image Value
--When calling for an icon for Key, replace with image Value, and optionally override type also
local imgOverrides = {
local imgOverrides = {
   ['Alt Magic'] = 'Magic',
   ['Alt Magic'] = 'Magic',
Line 166: Line 166:
   ['Basic Resupply'] = 'Lobster',
   ['Basic Resupply'] = 'Lobster',
   ['Standard Resupply'] = 'Crab',
   ['Standard Resupply'] = 'Crab',
   ['Generous Resupply'] = 'Shark'
   ['Generous Resupply'] = 'Shark',
  ['Cooking Upgrade 1'] = {'Cooking', 'skill'},
  ['Cooking Upgrade 2'] = {'Cooking', 'skill'}
}
}
--When calling for an icon for Key, the link goes to Value
--When calling for an icon for Key, the link goes to Value
Line 189: Line 191:
   local link = args[1]
   local link = args[1]
   local text = args[2]
   local text = args[2]
   local type = args.type
   local iconType = args.type
   local ext = args.ext ~= nil and args.ext or 'svg'
   local ext = args.ext ~= nil and args.ext or 'svg'
   local notext = args.notext ~= nil and args.notext ~= ''
   local notext = args.notext ~= nil and args.notext ~= ''
Line 209: Line 211:
   --MANUAL OVERRIDES
   --MANUAL OVERRIDES
   if imgOverrides[link] ~= nil and img == link then
   if imgOverrides[link] ~= nil and img == link then
    img = imgOverrides[link]
  local ovr = imgOverrides[link]
  if type(ovr) == 'string' then
  img = imgOverrides[link]
elseif type(ovr) == 'table' then
  img = ovr[1]
  if ovr[2] ~= nil then iconType = ovr[2] end
end
   end
   end
   if text == nil and txtOverrides[link] ~= nil then
   if text == nil and txtOverrides[link] ~= nil then
Line 218: Line 226:
     link = linkOverrides[link]
     link = linkOverrides[link]
   end
   end
   if typeExtOverrides[type] ~= nil and typeExtOverrides[type][img] ~= nil then
   if typeExtOverrides[iconType] ~= nil and typeExtOverrides[iconType][img] ~= nil then
   ext = typeExtOverrides[type][img]
   ext = typeExtOverrides[iconType][img]
   elseif extOverrides[img] ~= nil then  
   elseif extOverrides[img] ~= nil then  
     ext = extOverrides[img]
     ext = extOverrides[img]
   elseif type == 'mark' then
   elseif iconType == 'mark' then
     ext = 'png'
     ext = 'png'
   end
   end
   if typeOverrides[type] ~= nil then
   if typeOverrides[iconType] ~= nil then
     type = typeOverrides[type]
     iconType = typeOverrides[iconType]
   end
   end
   --There are a couple specific double overrides I want to include that don't fit in the above lists
   --There are a couple specific double overrides I want to include that don't fit in the above lists
   if Shared.contains(ambiguousOverrides, link) then
   if Shared.contains(ambiguousOverrides, link) then
     if text == nil then text = link end
     if text == nil then text = link end
     link = link..' ('..type..')'
     link = link..' ('..iconType..')'
   end
   end


Line 237: Line 245:
   local result = '[[File:'..img
   local result = '[[File:'..img
   --Add in type if one is set
   --Add in type if one is set
   if type ~= nil and type ~= '' then result = result..'_('..type..')' end
   if iconType ~= nil and iconType ~= '' then result = result..'_('..iconType..')' end
   --Add in extension and image size
   --Add in extension and image size
   result = result..'.'..ext..'|'..tostring(imgSize)..'x'..tostring(imgSize)..'px'  
   result = result..'.'..ext..'|'..tostring(imgSize)..'x'..tostring(imgSize)..'px'  
Line 278: Line 286:
     result = result..' [['..skill..']]'
     result = result..' [['..skill..']]'
   end
   end
  if level == nil then level = 'Unknown [[Category:Pages with script errors]]' end
   result = result.." Level "..level
   result = result.." Level "..level