12,704
edits
m (Remove local indexing of unused function) |
(Amend/fix overrides for Summoning marks) |
||
(48 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
local Shared = require("Module:Shared") | local Shared = require("Module:Shared") | ||
local GameData = require("Module:GameData") | |||
-- Locally index some functions for performance | -- Locally index some functions for performance | ||
Line 8: | Line 6: | ||
local p = {} | local p = {} | ||
--Extension overrides for items that have non- | --Extension overrides for items that have non-png images | ||
--Name level overrides take precedence over type level overrides | |||
local extOverrides = { | local extOverrides = { | ||
[" | ["type"] = { | ||
["skill"] = "svg", | |||
["spellType"] = "svg", | |||
["spell"] = "svg", | |||
["curse"] = "svg", -- Some exceptions included by name below | |||
["aurora"] = "svg", | |||
["combatArea"] = "svg", | |||
["dungeon"] = "svg", | |||
["prayer"] = "svg", | |||
["upgrade"] = "svg", -- Some exceptions included by name below | |||
["tree"] = "svg", | |||
["rock"] = "svg", -- Some exceptions included by name below | |||
["thieving"] = "svg", | |||
["constellation"] = "svg", | |||
["building"] = "svg", | |||
["resource"] = "svg", | |||
["township"] = "svg" | |||
[" | }, | ||
["name"] = { | |||
-- General | |||
["Combat"] = "svg", | |||
["Guides"] = "svg", | |||
["Mastery"] = "svg", | |||
["Coins"] = "svg", | |||
["Slayer Coins"] = "svg", | |||
["Raid Coins"] = "svg", | |||
["Shop"] = "svg", | |||
["Easter"] = "svg", | |||
["Melvor Logo"] = "svg", | |||
["Question"] = "svg", | |||
["Timer"] = "svg", | |||
["Hardcore"] = "svg", | |||
["Chaos"] = "svg", | |||
["Internal Suffering Speedrun"] = "svg", | |||
["Hardcore Adventure Speedrun"] = "svg", | |||
["Mastery Tokens"] = "gif", | |||
["Prat, the Serpent of Fire"] = "svg", | |||
-- Items | |||
["Amulet of Fishing"] = "svg", | |||
["Lemon"] = "jpg", | |||
["Lemons"] = "jpg", | |||
["Lemonade"] = "jpg", | |||
["Ancient Crossbow"] = "svg", | |||
["Air Shard"] = "svg", | |||
["Water Shard"] = "svg", | |||
["Earth Shard"] = "svg", | |||
["Fire Shard"] = "svg", | |||
["Confetti Crossbow"] = "svg", | |||
["Cloudburst Staff"] = "gif", | |||
["Shockwave"] = "svg", | |||
["Event Clue 1"] = "svg", | |||
["Event Clue 2"] = "svg", | |||
["Event Clue 3"] = "svg", | |||
["Event Clue 4"] = "svg", | |||
-- Pets | |||
["Cris"] = "svg", | |||
["Cool Rock"] = "svg", | |||
["Puff, the Baby Dragon"] = "svg", | |||
["Bruce"] = "svg", | |||
["Lil Ron"] = "svg", | |||
["Leonardo"] = "svg", | |||
["Golden Golbin"] = "svg", | |||
["Ty"] = "svg", | |||
["Ripper the Reindeer"] = "svg", | |||
["Chick"] = "svg", | |||
["Zarrah"] = "svg", | |||
["Chio"] = "svg", | |||
["Bouncing Bob"] = "svg", | |||
["Rosey"] = "svg", | |||
["Ayyden"] = "svg", | |||
["Arctic Yeti"] = "svg", | |||
["Mac"] = "svg", | |||
["Jerry the Giraffe"] = "svg", | |||
["Preston the Platypus"] = "svg", | |||
["Quill"] = "svg", | |||
["Gunter"] = "svg", | |||
["Salem"] = "svg", | |||
["Peri"] = "svg", | |||
["Otto"] = "svg", | |||
["Jelly Jim"] = "svg", | |||
["Harley"] = "svg", | |||
["Singe"] = "svg", | |||
["Aquarias"] = "svg", | |||
["Norman"] = "svg", | |||
["Erran"] = "svg", | |||
["Ren"] = "svg", | |||
["Pablo"] = "svg", | |||
["Sam"] = "svg", | |||
["Tim the Wolf"] = "svg", | |||
["Mark"] = "svg", | |||
["Astro"] = "svg", | |||
-- Curses, included to override the type level override above | |||
["Madness"] = "png", | |||
["Torment"] = "png", | |||
["Despair"] = "png", | |||
-- Alt. Magic | |||
["Rags to Riches III"] = "png", | |||
-- Upgrades, included to override the type level override above | |||
["Golbin Crate"] = "png", | |||
["Corundum Axe"] = "png", | |||
["Augite Axe"] = "png", | |||
["Meteorite Axe"] = "png", | |||
["Divine Axe"] = "png", | |||
["Spruce Cooking Fire"] = "png", | |||
["Elderwood Cooking Fire"] = "png", | |||
["Carrion Cooking Fire"] = "png", | |||
["Iridium Pot"] = "png", | |||
["Palladium Pot"] = "png", | |||
["Divine Pot"] = "png", | |||
["Corundum Furnace"] = "png", | |||
["Augite Furnace"] = "png", | |||
["Divine Furnace"] = "png", | |||
["Sign of the Stars"] = "png", | |||
["Summoner's Altar"] = "png", | |||
["Golden Shard"] = "png", | |||
["Labyrinth Solution"] = "png", | |||
["Linden Boat"] = "png", | |||
["Golden Compass"] = "png", | |||
-- Rocks (Mining), included to override the type level override above | |||
["Rune Essence"] = "png", | |||
["Pure Essence"] = "png", | |||
["Onyx"] = "png", | |||
["Oricha"] = "png", | |||
["Cerulean"] = "png", | |||
-- Marks (Summoning), included to override the type level override above | |||
["Eagle"] = "png", | |||
["Owl"] = "png", | |||
["Beaver"] = "png", | |||
["Fox"] = "png", | |||
["Lightning Spirit"] = "png", | |||
["Siren"] = "png", | |||
["Spider"] = "png", | |||
["Spectre"] = "png" | |||
} | |||
} | } | ||
--Some overrides only apply for a specific type | --Some overrides only apply for a specific type | ||
local typeExtOverrides = { | local typeExtOverrides = { | ||
[ | -- Example: ["item"] = { ["Chicken"] = "png" } | ||
["item"] = { | |||
-- These familiars also exist as type mark, where the image is of PNG format | |||
["Golbin Thief"] = "svg", | |||
["Occultist"] = "svg", | |||
["Wolf"] = "svg", | |||
["Ent"] = "svg", | |||
["Mole"] = "svg", | |||
["Octopus"] = "svg", | |||
["Minotaur"] = "svg", | |||
["Centaur"] = "svg", | |||
["Witch"] = "svg", | |||
["Pig"] = "svg", | |||
["Crow"] = "svg", | |||
["Leprechaun"] = "svg", | |||
["Cyclops"] = "svg", | |||
["Yak"] = "svg", | |||
["Unicorn"] = "svg", | |||
["Dragon"] = "svg", | |||
["Monkey"] = "svg", | |||
["Salamander"] = "svg", | |||
["Bear"] = "svg", | |||
["Devil"] = "svg" | |||
} | } | ||
} | |||
--When calling for an icon of type Key, instead use type Value | --When calling for an icon of type Key, instead use type Value | ||
Line 294: | Line 183: | ||
['Alt. Magic'] = 'Magic', | ['Alt. Magic'] = 'Magic', | ||
['Alternative Magic'] = 'Magic', | ['Alternative Magic'] = 'Magic', | ||
[' | ['Melee'] = {'Attack', 'skill'}, | ||
['Spider (lv. 51)'] = 'Spider', | ['Spider (lv. 51)'] = 'Spider', | ||
['Spider (lv. 52)'] = 'Brown Spider', | ['Spider (lv. 52)'] = 'Brown Spider', | ||
['Bane, Instrument of Fear'] = 'Bane', | |||
['Mastery Token Astrology'] = 'Mastery Token (Astrology)', | |||
['Event Token - Holiday 2021'] = 'Christmas Present (Yellow)', | |||
["I Can't See Helmet"] = {'Golbin', 'monster'}, | |||
-- Shop purchases | |||
['Basic Resupply'] = {'Lobster', 'item'}, | ['Basic Resupply'] = {'Lobster', 'item'}, | ||
['Standard Resupply'] = {'Crab', 'item'}, | ['Standard Resupply'] = {'Crab', 'item'}, | ||
['Generous Resupply'] = {'Shark', 'item'}, | ['Generous Resupply'] = {'Shark', 'item'}, | ||
['Plentiful Resupply'] = {'Magma Fish', 'item'}, | |||
['Bountiful Resupply'] = {'Static Jellyfish', 'item'}, | |||
['Cooking Upgrade 1'] = {'Cooking', 'skill'}, | ['Cooking Upgrade 1'] = {'Cooking', 'skill'}, | ||
['Cooking Upgrade 2'] = {'Cooking', 'skill'}, | ['Cooking Upgrade 2'] = {'Cooking', 'skill'}, | ||
['Loot Container Stacking'] = {'Amulet of Looting', 'item'}, | ['Loot Container Stacking'] = {'Amulet of Looting', 'item'}, | ||
[' | ['Access to Throne of the Herald'] = {'Golden Key', 'item'}, | ||
[' | ["Max Skillcape"] = 'Maximum Skillcape', | ||
[' | -- Alt.Magic spells using item icons | ||
[" | ['Item Alchemy'] = {'Item Alchemy III', 'spell'}, | ||
['Superheat'] = {'Superheat IV', 'spell'}, | |||
["Holy Invocation I"] = {'Small Urn', 'item'}, | |||
["Holy Invocation II"] = {'Medium Urn', 'item'}, | |||
["Nullification"] = {'Rune Essence', 'item'}, | |||
["Transmutation"] = {'Oricha', 'item'}, | |||
["Purification"] = {'Pure Essence', 'item'}, | |||
["Fragmentation"] = {'Summoning Shard (Black)', 'item'}, | |||
["Holy Invocation III"] = {'Large Urn', 'item'}, | |||
["Embellish"] = {'Lava Fish (Perfect)', 'item'}, | |||
-- Overrides that allow generic potion pages to be linked to easily | -- Overrides that allow generic potion pages to be linked to easily | ||
['Melee Accuracy Potion'] = {'Melee Accuracy Potion I', 'item'}, | ['Melee Accuracy Potion'] = {'Melee Accuracy Potion I', 'item'}, | ||
Line 325: | Line 228: | ||
['Diamond Luck Potion'] = {'Diamond Luck Potion I', 'item'}, | ['Diamond Luck Potion'] = {'Diamond Luck Potion I', 'item'}, | ||
['Damage Reduction Potion'] = {'Damage Reduction Potion I', 'item'}, | ['Damage Reduction Potion'] = {'Damage Reduction Potion I', 'item'}, | ||
['Area Control Potion'] = {'Area Control Potion I', 'item'}, | |||
['Adaptive Defence Potion'] = {'Adaptive Defence Potion I', 'item'}, | |||
['Slayer Bounty Potion'] = {'Slayer Bounty Potion I', 'item'}, | |||
['Holy Bulwark Potion'] = {'Holy Bulwark Potion I', 'item'}, | |||
['Adaptive Accuracy'] = {'Adaptive Accuracy Potion I', 'item'}, | |||
['Reaper Potion'] = {'Reaper Potion I', 'item'}, | |||
['Penetration Potion'] = {'Penetration Potion I', 'item'}, | |||
['Critical Strike Potion'] = {'Critical Strike Potion I', 'item'}, | |||
['Bird Nest Potion'] = {'Bird Nest Potion I', 'item'}, | ['Bird Nest Potion'] = {'Bird Nest Potion I', 'item'}, | ||
['Controlled Heat Potion'] = {'Controlled Heat Potion I', 'item'}, | ['Controlled Heat Potion'] = {'Controlled Heat Potion I', 'item'}, | ||
['Generous Cook Potion'] = {'Generous Cook Potion I', 'item'}, | ['Generous Cook Potion'] = {'Generous Cook Potion I', 'item'}, | ||
['Seeing Gold Potion'] = {'Seeing Gold Potion I', 'item'}, | |||
['Fishermans Potion'] = {'Fishermans Potion I', 'item'}, | ['Fishermans Potion'] = {'Fishermans Potion I', 'item'}, | ||
['Skilled Fletching Potion'] = {'Skilled Fletching Potion I', 'item'}, | ['Skilled Fletching Potion'] = {'Skilled Fletching Potion I', 'item'}, | ||
Line 339: | Line 251: | ||
['Herblore Potion'] = {'Herblore Potion I', 'item'}, | ['Herblore Potion'] = {'Herblore Potion I', 'item'}, | ||
['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'}, | ['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'}, | ||
[' | ['Alchemic Practice Potion'] = {'Alchemic Practice Potion I', 'item'}, | ||
['Gem Detector Potion'] = {'Gem Detector Potion I', 'item'}, | |||
['Multicooker Potion'] = {'Multicooker Potion I', 'item'}, | |||
['Star Seeker Potion'] = {'Star Seeker Potion I', 'item'}, | |||
['Traps Potion'] = {'Traps Potion I', 'item'}, | |||
['Enkindled Yields Potion'] = {'Enkindled Yields Potion I', 'item'}, | |||
['Alt Magic Potion'] = {'Alt Magic Potion I', 'item'}, | |||
-- Township resources | |||
['GP'] = {'Coins', ''}, | |||
['Food'] = {'Raw Beef', 'item'}, | |||
['Ore'] = {'Iron', 'rock'}, | |||
['Bar'] = {'Iron Bar', 'item'}, | |||
['Herbs'] = {'Garum Herb', 'item'}, | |||
['Clothing'] = {'Leather Body', 'item'}, | |||
-- Township generic statue building | |||
['Statue of Worship'] = 'Statue of Nothing', | |||
-- Easter egg stuff | |||
["Lemonade (Empty)"] = "Lemonade", | |||
["Lemonade (Very empty)"] = "Lemonade", | |||
["Lemonade (Still very empty)"] = "Lemonade", | |||
["Lemonade (Not as empty as before)"] = "Lemonade", | |||
["Lemonade (Not much)"] = "Lemonade", | |||
["Lemonade (Has a bit now)"] = "Lemonade", | |||
["Lemonade (A little bit more now)"] = "Lemonade", | |||
["Lemonade (Half full)"] = "Lemonade", | |||
["Lemonade (Just over half full)"] = "Lemonade", | |||
["Lemonade (Maybe this is half full?)"] = "Lemonade", | |||
["Lemonade (Nope this is half full now)"] = "Lemonade", | |||
["Lemonade (Wow this is slow)"] = "Lemonade", | |||
["Lemonade (Just fill it up already)"] = "Lemonade", | |||
["Lemonade (Still not full)"] = "Lemonade", | |||
["Lemonade (Again, still not full)"] = "Lemonade", | |||
["Lemonade (Less than before because you drank some)"] = "Lemonade", | |||
["Lemonade (Back to where we were before)"] = "Lemonade", | |||
["Lemonade (Almost full)"] = "Lemonade", | |||
["Lemonade (Still almost full)"] = "Lemonade", | |||
["Lemonade (How full is it supposed to be?)"] = "Lemonade", | |||
["Lemonade (Wait this might be half full now)"] = "Lemonade", | |||
["Lemonade (Haha just joking, hurry up)"] = "Lemonade", | |||
["Lemonade (Okay this looks pretty full now)"] = "Lemonade", | |||
["Lemonade (Now?)"] = "Lemonade", | |||
["Lemonade (What about now?)"] = "Lemonade", | |||
["Lemonade (YAY ITS FINALLY FULL!)"] = "Lemonade", | |||
["Lemonade (Oh... still not full)"] = "Lemonade", | |||
["Lemonade (Wait for it)"] = "Lemonade", | |||
["Lemonade (Wait for it!)"] = "Lemonade", | |||
["Lemonade (Full)"] = "Lemonade" | |||
} | |||
--When calling for an icon for Key + Type, replace with image Value, and optionally override type also | |||
local typeImgOverrides = { | |||
['resource'] = { | |||
['Rune Essence'] = {'Rune Essence', 'item'}, | |||
['Leather'] = {'Leather', 'item'}, | |||
} | |||
} | } | ||
--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 345: | Line 310: | ||
['Alt Magic'] = 'Alternative Magic', | ['Alt Magic'] = 'Alternative Magic', | ||
['Alt. Magic'] = 'Alternative Magic', | ['Alt. Magic'] = 'Alternative Magic', | ||
['Spider2'] = 'Brown Spider | ['Spider2'] = 'Brown Spider' | ||
} | } | ||
--When calling for an icon for Key + Type, the link goes to Value | |||
local typeLinkOverrides = { | |||
['resource'] = { | |||
-- Township resources | |||
['Food'] = '', | |||
['Wood'] = '', | |||
['Planks'] = '', | |||
['Stone'] = '', | |||
['Bar'] = '', | |||
['Ore'] = '', | |||
['Coal'] = '', | |||
['Rune Essence'] = '', | |||
['Herbs'] = '', | |||
['Potions'] = '', | |||
['Leather'] = '', | |||
['Clothing'] = '' | |||
}, | |||
['township'] = { | |||
['Workers'] = '', | |||
['Statistics'] = '', | |||
['Town'] = '' | |||
} | |||
} | |||
--If no other text override was specified for the given link, use these | --If no other text override was specified for the given link, use these | ||
local txtOverrides = { | local txtOverrides = { | ||
Line 368: | Line 346: | ||
['Chicken'] = true, | ['Chicken'] = true, | ||
['Cyclops'] = true, | ['Cyclops'] = true, | ||
['Wizard'] = true | ['Wizard'] = true, | ||
['Spider'] = true, | |||
['Necromancer'] = true, | |||
['Dark Knight'] = true, | |||
['Vampire'] = true, | |||
['Phantom'] = true, | |||
['Spectre'] = true, | |||
['Siren'] = true, | |||
['Lightning Spirit'] = true, | |||
} | |||
--When calling for an icon for Key, add a css class | |||
local imgClassOverrides = { | |||
-- Township Stat Icons are licensed from Font Awesome Free 5.14.0 under CC BY 4.0 (https://github.com/FortAwesome/Font-Awesome/tree/5.14.0) | |||
['Population'] = 'township-colortoggle', | |||
['Workers'] = 'township-colortoggle', | |||
['Storage'] = 'township-colortoggle', | |||
} | } | ||
Line 376: | Line 369: | ||
local text = args[2] | local text = args[2] | ||
local iconType = args.type | local iconType = args.type | ||
local ext = args.ext ~= nil and args.ext ~= '' and args.ext or ' | local ext = args.ext ~= nil and args.ext ~= '' and args.ext or 'png' | ||
local notext = args.notext ~= nil and args.notext ~= '' | local notext = args.notext ~= nil and args.notext ~= '' | ||
local nolink = args.nolink ~= nil and args.nolink ~= '' | local nolink = args.nolink ~= nil and args.nolink ~= '' | ||
Line 384: | Line 377: | ||
local qty = args.qty | local qty = args.qty | ||
local img = args.img ~= nil and args.img ~= '' and args.img or link | local img = args.img ~= nil and args.img ~= '' and args.img or link | ||
local class = args.class ~= nil and args.class ~= '' and args.class or '' | |||
local altText = args.alt ~= nil and args.alt or (notext and (text or link)) or '' | |||
local nospan = args.nospan ~= nil and args.nospan | |||
link = fixPagename(link) | link = fixPagename(link) | ||
Line 395: | Line 391: | ||
--MANUAL OVERRIDES | --MANUAL OVERRIDES | ||
local ovrImg = imgOverrides[link] | local ovrImg = imgOverrides[link] | ||
local ovrTypeImg = typeImgOverrides[iconType] | |||
if ovrTypeImg ~= nil then | |||
ovrImg = ovrTypeImg ~= nil and ovrTypeImg[img] or ovrImg | |||
end | |||
local ovrTxt = txtOverrides[link] | local ovrTxt = txtOverrides[link] | ||
local ovrLink = linkOverrides[link] | local ovrLink = linkOverrides[link] | ||
local | local ovrTypeLink = typeLinkOverrides[iconType] | ||
if | if ovrTypeLink ~= nil and ovrTypeLink[img] ~= nil then | ||
if ovrTypeLink[img] == '' then | |||
nolink = true | |||
else | |||
ovrLink = ovrTypeLink[img] | |||
end | |||
end | end | ||
local hasText = (text ~= nil and text ~= '') | local hasText = (text ~= nil and text ~= '') | ||
if ovrImg ~= nil and img == link then | if ovrImg ~= nil and img == link then | ||
Line 411: | Line 413: | ||
if ovrImg[2] ~= nil then iconType = ovrImg[2] end | if ovrImg[2] ~= nil then iconType = ovrImg[2] end | ||
end | end | ||
end | |||
local ovrClass = imgClassOverrides[link] | |||
-- Type & extension overrides must be after adjustments have been made | |||
-- for any image overrides | |||
local ovrTypeExt = typeExtOverrides[iconType] | |||
if ovrTypeExt ~= nil then | |||
ovrTypeExt = ovrTypeExt[img] | |||
end | |||
local ovrType = typeOverrides[iconType] | |||
local ovrExt = extOverrides.name[img] | |||
if ovrExt == nil then | |||
ovrExt = extOverrides.type[ovrType or iconType] | |||
end | end | ||
if not hasText and ovrTxt ~= nil then | if not hasText and ovrTxt ~= nil then | ||
text = ovrTxt | text = ovrTxt | ||
hasText = true | |||
end | end | ||
if ovrLink ~= nil then | if ovrLink ~= nil then | ||
if not hasText then text = link end | if not hasText then | ||
text = link | |||
hasText = true | |||
end | |||
link = ovrLink | link = ovrLink | ||
end | end | ||
Line 423: | Line 441: | ||
elseif ovrExt ~= nil then | elseif ovrExt ~= nil then | ||
ext = ovrExt | ext = ovrExt | ||
end | end | ||
if ovrType ~= nil then | if ovrType ~= nil then | ||
iconType = ovrType | iconType = ovrType | ||
end | |||
if ovrClass ~= nil then | |||
class = ovrClass | |||
end | end | ||
-- There are a couple specific double overrides to be included that don't fit in the above lists | -- There are a couple specific double overrides to be included that don't fit in the above lists | ||
if ambiguousOverrides[link] then | if ambiguousOverrides[link] then | ||
if not hasText then text = link end | if not hasText then | ||
text = link | |||
hasText = true | |||
end | |||
link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')' | link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')' | ||
end | end | ||
Line 442: | Line 464: | ||
local txtImg = (iconType ~= nil and iconType ~= '' and img .. '_(' .. iconType .. ')' or img) .. '.' .. ext | local txtImg = (iconType ~= nil and iconType ~= '' and img .. '_(' .. iconType .. ')' or img) .. '.' .. ext | ||
-- Include a link unless no link -and- no text was requested | -- Include a link unless no link -and- no text was requested | ||
local txtLink = | local txtLink = '|link=' .. (nolink and '' or link) | ||
resultText = '[[File:' .. txtImg .. '|' .. txtSize .. 'x' .. txtSize .. 'px' .. txtLink .. ']]' | resultText = '[[File:' .. txtImg .. '|' .. txtSize .. 'x' .. txtSize .. 'px|alt=' .. altText .. txtLink .. ']]' | ||
if class ~= nil and class ~= '' then | |||
resultText = '<span class="'..class..'">'..resultText..'</span>' | |||
end | |||
end | end | ||
Line 462: | Line 487: | ||
if menu then | if menu then | ||
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}' | return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}' | ||
elseif not noicon then | elseif not noicon and not nospan then | ||
return '<span style="display:inline-block">' .. resultText .. '</span>' | return '<span style="display:inline-block">' .. resultText .. '</span>' | ||
else | else | ||
Line 477: | Line 502: | ||
function p._SkillReq(skill, level, showText) | function p._SkillReq(skill, level, showText) | ||
local result = p.Icon({skill, type='skill', notext='true | local altText = (showText and '') or skill | ||
local result = p.Icon({skill, type='skill', notext=(showText and '' or true), nospan=true, alt=altText}) | |||
if level == nil then level = 'Unknown [[Category:Pages with script errors]]' end | if level == nil then level = 'Unknown [[Category:Pages with script errors]]' end | ||
result = result.." Level "..level | result = result.." Level "..level | ||
Line 505: | Line 528: | ||
iconname = linkname..' I' | iconname = linkname..' I' | ||
end | end | ||
local altTextItem = (showText and '') or linkname | |||
local altTextMastery = (showText and '') or ' Mastery' | |||
local result = 'Level '..level..' ' | local result = 'Level '..level..' ' | ||
result = result..p.Icon({linkname, img=iconname, type='item', notext = true})..p.Icon({'Mastery', notext=true}) | result = result..p.Icon({linkname, img=iconname, type='item', notext=true, nospan=true, alt=altTextItem})..p.Icon({'Mastery', notext=true, nospan=true, alt=altTextMastery}) | ||
if showText then result = result..'[['..linkname..']] [[Mastery]]' end | if showText then result = result..'[['..linkname..']] [[Mastery]]' end | ||
result = '<span style="display:inline-block">'..result..'</span>' | result = '<span style="display:inline-block">'..result..'</span>' | ||
Line 521: | Line 546: | ||
end | end | ||
function p._Currency(fileName, link, amt, maxAmt) | function p._Currency(fileName, link, altText, amt, maxAmt) | ||
local amtText = formatnum(amt) | local amtText = formatnum(amt) | ||
if maxAmt ~= nil and maxAmt >= amt then | if maxAmt ~= nil and maxAmt >= amt then | ||
Line 533: | Line 558: | ||
fileText = fileText .. '|link=' .. link | fileText = fileText .. '|link=' .. link | ||
end | end | ||
fileText = fileText .. ']] ' | fileText = fileText .. '|alt=' .. ((altText == nil and '') or altText) .. ']] ' | ||
end | end | ||
Line 540: | Line 565: | ||
function p.GP(amt, maxamt) | function p.GP(amt, maxamt) | ||
return p._Currency('Coins.svg', 'Coins', amt, maxamt) | return p._Currency('Coins.svg', 'Coins', 'GP', amt, maxamt) | ||
end | end | ||
function p.SC(amt, maxamt) | function p.SC(amt, maxamt) | ||
return p._Currency('Slayer Coins.svg', 'Currency#Slayer Coins', amt, maxamt) | return p._Currency('Slayer Coins.svg', 'Currency#Slayer Coins', 'SC', amt, maxamt) | ||
end | end | ||
function p.RC(amt, maxamt) | function p.RC(amt, maxamt) | ||
return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', amt, maxamt) | return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', 'RC', amt, maxamt) | ||
end | |||
--Adding a shortcut function for this | |||
function p.TotH() | |||
return p.Icon({'Throne of the Herald Expansion', ext='svg', notext=true, img='TotH'}) | |||
end | |||
function p.getExpansionIcon(id) | |||
local ns, _ = GameData.getLocalID(id) | |||
if ns == 'melvorTotH' then | |||
return p.TotH()..' ' | |||
else | |||
return '' | |||
end | |||
end | end | ||
return p | return p |