Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
Added MasteryReq function
(Moved quantity in front of icon to match game's formatting)
(Added MasteryReq function)
Line 88: Line 88:


function p._SkillReq(skill, level, showText)
function p._SkillReq(skill, level, showText)
   local result = '[[File:'..skill..'_(skill).svg|25px|link='..skill..']]'
   local result = Icons.Icon({skill, type='skill', notext='true'})
   if showText then
   if showText then
     result = result..' [['..skill..']]'
     result = result..' [['..skill..']]'
Line 104: Line 104:
   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._SkillReq(skill, level, showText)
   return p._SkillReq(skill, level, showText)
end
function p._MasteryReq(itemName, level, showText)
  local iconname = itemName
  local linkname = itemName
  --First, go with the lowest tier of potions if a potion is mentioned
  local s, e = string.find(itemName, 'Potion')
  if e ~= nil then
    linkname = string.sub(itemName, 1, e)
    iconname = linkname..' I'
  end
  local result = 'Level '..level..' '
  result = result..p.Icon({linkname, img=iconname, type='item', notext = true})..p.Icon({'Mastery', notext=true})
  if showText  then result = result..'[['..linkname..']] [[Mastery]]' end
  result = '<span style="display:inline-block">'..result..'</span>'
  return result
end
function p.MasteryReq(frame)
  local args = frame.args ~= nil and frame.args or frame
  local itemName = args[1]
  local level = tonumber(args[2])
  local showText = args.showText ~= nil and args.showText ~= '' and args.showText ~= 'false'
  return p._MasteryReq(itemName, level, showText)
end
end