Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
1,072 bytes added ,  7 October 2020
Changed how icon overrides work to make adding more cleaner
(fixed issue)
(Changed how icon overrides work to make adding more cleaner)
Line 16: Line 16:
   ["Cloudburst Staff"] = "png",
   ["Cloudburst Staff"] = "png",
   ["Earth Layered Shield"] = "png",
   ["Earth Layered Shield"] = "png",
}
--When calling for an icon of type Key, instead use type Value
local typeOverrides = {
  ['combat'] = 'combatArea',
  ['slayer'] = 'combatArea',
}
--When calling for an icon for Key, replace with image Value
local imgOverrides = {
  ['Alt Magic'] = 'Magic',
  ['Alt. Magic'] = 'Magic',
  ['Alternative Magic'] = 'Magic',
  ['Melee'] = 'Combat',
  ['Spider (lv. 51)'] = 'Spider',
  ['Spider (lv. 52)'] = 'Spider2'
}
--When calling for an icon for Key, the link goes to Value
local linkOverrides = {
  ['Alt Magic'] = 'Alternative Magic',
  ['Alt. Magic'] = 'Alternative Magic',
  ['Spider'] = 'Spider (lv. 51)',
  ['Spider2'] = 'Spider (lv. 52)'
}
--If no other text override was specified for the given link, use these
local txtOverrides = {
  ['Spider'] = 'Spider (lv. 51)',
  ['Spider2'] = 'Spider (lv. 52)'
}
}


Line 34: Line 61:


   --MANUAL OVERRIDES
   --MANUAL OVERRIDES
   if link == 'Melee' then
   if imgOverrides[link] ~= nil and img == link then
     img = 'Combat'
     img = imgOverrides[link]
   elseif link == 'Spider (lv. 51)' then
  end
     img = 'Spider'
   if text == nil and txtOverrides[link] ~= nil then
   elseif link == 'Spider (lv. 52)' then
     text = txtOverrides[link]
     img = 'Spider2'
  end
  elseif link == 'Spider' then
   if linkOverrides[link] ~= nil then
     link = 'Spider (lv. 51)'
     if text == nil then text = link end
   elseif link == 'Spider2' then
     link = linkOverrides[link]
     link = 'Spider (lv. 52)'
  end
   elseif link == 'Alt. Magic' or link == 'Alternative Magic' or link == 'Alt Magic' then
   if extOverrides[img] ~= nil then  
     text = link
     ext = extOverrides[img]
    img = 'Magic'
  end
     link = 'Alternative Magic'
  --There are a couple specific double overrides I want to include that don't fit in the above lists
    type = 'skill'
   if link == 'Golbin' then
     if text == nil then text = 'Golbin' end
     link = 'Golbin ('..type..')'
   end
   end


   if extOverrides[img] ~= nil then ext = extOverrides[img] end
   --Creating the image...
 
   local result = '[[File:'..img
   local result = '[[File:'..img
  --Add in type if one is set
   if type ~= nil and type ~= '' then result = result..'_('..type..')' end
   if type ~= nil and type ~= '' then result = result..'_('..type..')' end
  --Add in extension and image size
   result = result..'.'..ext..'|'..tostring(imgSize)..'x'..tostring(imgSize)..'px'  
   result = result..'.'..ext..'|'..tostring(imgSize)..'x'..tostring(imgSize)..'px'  
  --Include a link unless no link -and- no text was requested
   if not (nolink and notext) then result = result..'|link='..link end
   if not (nolink and notext) then result = result..'|link='..link end
   result = result..']]'
   result = result..']]'
 
 
  --Add Quantity to the front if requested
   if qty ~= nil and qty ~= '' then result = Shared.formatnum(qty)..' '..result end
   if qty ~= nil and qty ~= '' then result = Shared.formatnum(qty)..' '..result end


Line 70: Line 102:
     else
     else
       result = result..' [['..link
       result = result..' [['..link
       if text ~= nil and text ~= '' then
       if text ~= nil and text ~= '' and text ~= link then
         result = result..'|'..text
         result = result..'|'..text
       end
       end