Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
Adding overrides for resupplies.
(Only show a range of values for GP/SP if the values are actually different)
(Adding overrides for resupplies.)
(3 intermediate revisions by 2 users not shown)
Line 47: Line 47:
   ['Melee'] = 'Combat',
   ['Melee'] = 'Combat',
   ['Spider (lv. 51)'] = 'Spider',
   ['Spider (lv. 51)'] = 'Spider',
   ['Spider (lv. 52)'] = 'Spider2'
   ['Spider (lv. 52)'] = 'Spider2',
  ['Basic Resupply'] = 'Lobster',
  ['Standard Resupply'] = 'Crab',
  ['Generous Resupply'] = 'Shark'
}
}
--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 61: Line 64:
   ['Spider2'] = 'Spider (lv. 52)'
   ['Spider2'] = 'Spider (lv. 52)'
}
}
--Ambiguous overrides section
local ambiguousOverrides = {'Golbin', 'Chick'}


local Shared= require("Module:Shared")
local Shared= require("Module:Shared")
Line 104: Line 109:
   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 link == 'Golbin' then
   if Shared.contains(ambiguousOverrides, link) then
     if text == nil then text = 'Golbin' end
     if text == nil then text = link end
     link = 'Golbin ('..type..')'
     link = link..' ('..type..')'
   end
   end


Line 190: Line 195:
   local showText = args.showText ~= nil and args.showText ~= '' and args.showText ~= 'false'
   local showText = args.showText ~= nil and args.showText ~= '' and args.showText ~= 'false'
   return p._MasteryReq(itemName, level, showText)
   return p._MasteryReq(itemName, level, showText)
end
function p._Currency(fileName, link, amt, maxAmt)
  local amtText = Shared.formatnum(amt)
  if maxAmt ~= nil and maxAmt >= amt then
    amtText = amtText .. ' - ' .. Shared.formatnum(maxAmt)
  end
  local fileText = ''
  if fileName ~= nil then
    fileText = '[[File:' .. fileName .. '|25px'
    if link ~= nil then
      fileText = fileText .. '|link=' .. link
    end
    fileText = fileText .. ']] '
  end
  return '<span style="display:inline-block">' .. fileText .. amtText .. '</span>'
end
end


function p.GP(amt, maxamt)
function p.GP(amt, maxamt)
   local result = '[[File:Coins.svg|25px|link=Coins]]'
   return p._Currency('Coins.svg', 'Coins', amt, maxamt)
  result = result..'&nbsp;'..Shared.formatnum(amt)
  if maxamt ~= nil and maxamt ~= amt then result = result..' - '..Shared.formatnum(maxamt) end
 
  result = '<span style="display:inline-block">'..result..'</span>'
  return result
end
end


function p.SC(amt, maxamt)
function p.SC(amt, maxamt)
   local result = '[[File:Slayer Coins.svg|25px|link=Currency#Slayer Coins]]'
   return p._Currency('Slayer Coins.svg', 'Currency#Slayer Coins', amt, maxamt)
  result = result..'&nbsp;'..Shared.formatnum(amt)
end
  if maxamt ~= nil and maxamt ~= amt then result = result..' - '..Shared.formatnum(maxamt) end


   result = '<span style="display:inline-block">'..result..'</span>'
function p.RC(amt, maxamt)
  return result
   return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', amt, maxamt)
end
end


return p
return p