Module:Icons: Difference between revisions

From Melvor Idle
m (' -> ')
(Icon: Modify link logic to prevent linking to File pages when nolink is specified)
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
--You can't generate Templates from within Lua due to the loading order, so instead copying the Icon functionality into a module so it can be pulled elsewhere.
--You can't generate Templates from within Lua due to the loading order, so instead copying the Icon functionality into a module so it can be pulled elsewhere.
--Should function very similarly to how Template:Icon works
--Should function very similarly to how Template:Icon works
local Shared = require("Module:Shared")
-- Locally index some functions for performance
local sgsub, fixPagename, formatnum, tostring, type = string.gsub, Shared.fixPagename, Shared.formatnum, tostring, type


local p = {}
local p = {}
--Extension overrides for items that have non-svg images
--Extension overrides for items that have non-svg images
local extOverrides = {
local extOverrides = {
  ["Crown of Rhaelyx"] = "png",
["Adventure"] = "png",
  ["Jewel of Rhaelyx"] = "png",
["Crown of Rhaelyx"] = "png",
  ["Circlet of Rhaelyx"] = "png",
["Jewel of Rhaelyx"] = "png",
  ["Charge Stone of Rhaelyx"] = "png",
["Circlet of Rhaelyx"] = "png",
  ["Mysterious Stone"] = "png",
["Charge Stone of Rhaelyx"] = "png",
  ["Cloudburst Staff"] = "png",
["Mysterious Stone"] = "png",
  ["Earth Layered Shield"] = "png",
["Lemon"] = "jpg",
  ["Lemon"] = "jpg",
["Lemons"] = "jpg",
  ["Lemons"] = "jpg",
["Lemonade"] = "jpg",
  ["Lemonade"] = "jpg",
["Miolite Sprig"] = "png",
  ["Miolite Sprig"] = "png",
["Miolite Trio"] = "png",
  ["Miolite Trio"] = "png",
["Miolite Warden"] = "png",
  ["Miolite Warden"] = "png",
["Miolite Monarch"] = "png",
  ["Miolite Monarch"] = "png",
["Wicked Greater Dragon"] = "png",
  ["Wicked Greater Dragon"] = "png",
["Hunting Greater Dragon"] = "png",
  ["Hunting Greater Dragon"] = "png",
["Chaotic Greater Dragon"] = "png",
  ["Chaotic Greater Dragon"] = "png",
["Beavis"] = "png",
  ["Beavis"] = "png",
["Pudding Duckie"] = "png",
  ["Pudding Duckie"] = "png",
["Pyro"] = "png",
  ["Pyro"] = "png",
["Snek"] = "png",
  ["Snek"] = "png",
["Larry, the Lonely Lizard"] = "png",
  ["Larry, the Lonely Lizard"] = "png",
["Caaarrrlll"] = "png",
  ["Caaarrrlll"] = "png",
["Gronk"] = "png",
  ["Gronk"] = "png",
["Finn, the Cat"] = "png",
  ["Finn, the Cat"] = "png",
["Marahute"] = "png",
  ["Marahute"] = "png",
["Monk-ey"] = "png",
  ["Monk-ey"] = "png",
["Asura"] = "png",
  ["Asura"] = "png",
["Summoning Shard (Silver)"] = "png",
  ["Summoning Shard (Silver)"] = "png",
["Summoning Shard (Red)"] = "png",
  ["Summoning Shard (Red)"] = "png",
["Summoning Shard (Green)"] = "png",
  ["Summoning Shard (Green)"] = "png",
["Summoning Shard (Gold)"] = "png",
  ["Summoning Shard (Gold)"] = "png",
["Summoning Shard (Blue)"] = "png",
  ["Summoning Shard (Blue)"] = "png",
["Summoning Shard (Black)"] = "png",
  ["Summoning Shard (Black)"] = "png",
['Infernal Core'] = 'png',
  ['Infernal Core'] = 'png',
['Cool Glasses'] = 'png',
  ['Cool Glasses'] = 'png',
["Wizard's Sigil"] = 'png',
  ["Wizard's Sigil"] = 'png',
["Wizard's Scroll"] = 'png',
  ["Wizard's Scroll"] = 'png',
["Whetstone"] = 'png',
  ["Whetstone"] = 'png',
["Whale (Perfect)"] = 'png',
  ["Whale (Perfect)"] = 'png',
["Trout (Perfect)"] = 'png',
  ["Trout (Perfect)"] = 'png',
["Training Shield"] = 'png',
  ["Training Shield"] = 'png',
["Thiever's Cape"] = 'png',
  ["Thiever's Cape"] = 'png',
["Thief's Moneysack"] = 'png',
  ["Thief's Moneysack"] = 'png',
["Swordfish (Perfect)"] = 'png',
  ["Swordfish (Perfect)"] = 'png',
["Strawberry Cupcake (Perfect)"] = 'png',
  ["Strawberry Cupcake (Perfect)"] = 'png',
["Strawberry Cupcake"] = 'png',
  ["Strawberry Cupcake"] = 'png',
["Strawberry Cake (Perfect)"] = 'png',
  ["Strawberry Cake (Perfect)"] = 'png',
["Strawberry Cake"] = 'png',
  ["Strawberry Cake"] = 'png',
["Stack of Bones"] = 'png',
  ["Stack of Bones"] = 'png',
["Sneak-Ers"] = 'png',
  ["Sneak-Ers"] = 'png',
["Shrimp (Perfect)"] = 'png',
  ["Shrimp (Perfect)"] = 'png',
["Shipwheel"] = 'png',
  ["Shipwheel"] = 'png',
["Shark (Perfect)"] = 'png',
  ["Shark (Perfect)"] = 'png',
["Seed Pouch"] = 'png',
  ["Seed Pouch"] = 'png',
["Seahorse (Perfect)"] = 'png',
  ["Seahorse (Perfect)"] = 'png',
["Sardine (Perfect)"] = 'png',
  ["Sardine (Perfect)"] = 'png',
["Salmon (Perfect)"] = 'png',
  ["Salmon (Perfect)"] = 'png',
["Sailor's Top"] = 'png',
  ["Sailor's Top"] = 'png',
["Runecrafting Pouch"] = 'png',
  ["Runecrafting Pouch"] = 'png',
["Ring of Wealth"] = 'png',
  ["Ring of Wealth"] = 'png',
["Raw Chicken"] = 'png',
  ["Raw Chicken"] = 'png',
["Raw Beef"] = 'png',
  ["Raw Beef"] = 'png',
["Prayer Scroll"] = 'png',
  ["Prayer Scroll"] = 'png',
["Plain Pizza Slice (Perfect)"] = 'png',
  ["Plain Pizza Slice (Perfect)"] = 'png',
["Plain Pizza Slice"] = 'png',
  ["Plain Pizza Slice"] = 'png',
["Pile of Ores"] = 'png',
  ["Pile of Ores"] = 'png',
["Pile of Logs"] = 'png',
  ["Pile of Logs"] = 'png',
["Miner's Helmet"] = 'png',
  ["Miner's Helmet"] = 'png',
["Merchant's Permit"] = 'png',
  ["Merchant's Permit"] = 'png',
["Meat Pizza Slice (Perfect)"] = 'png',
  ["Meat Pizza Slice (Perfect)"] = 'png',
["Meat Pizza Slice"] = 'png',
  ["Meat Pizza Slice"] = 'png',
["Marksman's Sigil"] = 'png',
  ["Marksman's Sigil"] = 'png',
["Manta Ray (Perfect)"] = 'png',
  ["Manta Ray (Perfect)"] = 'png',
["Lumberjack's Top"] = 'png',
  ["Lumberjack's Top"] = 'png',
["Lobster (Perfect)"] = 'png',
  ["Lobster (Perfect)"] = 'png',
["Lemon Cake (Perfect)"] = 'png',
  ["Lemon Cake (Perfect)"] = 'png',
["Lemon Cake"] = 'png',
  ["Lemon Cake"] = 'png',
["Knight's Sigil"] = 'png',
  ["Knight's Sigil"] = 'png',
["Knight's Defender"] = 'png',
  ["Knight's Defender"] = 'png',
["Knight's Cape"] = 'png',
  ["Knight's Cape"] = 'png',
["Jeweled Necklace"] = 'png',
  ["Jeweled Necklace"] = 'png',
["Jester's Hat"] = 'png',
  ["Jester's Hat"] = 'png',
["Jadestone"] = 'png',
  ["Jadestone"] = 'png',
["Herring (Perfect)"] = 'png',
  ["Herring (Perfect)"] = 'png',
["Hearty Soup (Perfect)"] = 'png',
  ["Hearty Soup (Perfect)"] = 'png',
["Hearty Soup"] = 'png',
  ["Hearty Soup"] = 'png',
["Gold Crested Shield"] = 'png',
  ["Gold Crested Shield"] = 'png',
["Golbin Mask"] = 'png',
  ["Golbin Mask"] = 'png',
["Giant Club"] = 'png',
  ["Giant Club"] = 'png',
["Fishing Hook"] = 'png',
  ["Fishing Hook"] = 'png',
["Fine Coinpurse"] = 'png',
  ["Fine Coinpurse"] = 'png',
["Fanfish (Perfect)"] = 'png',
  ["Fanfish (Perfect)"] = 'png',
["Cream Corn Soup (Perfect)"] = 'png',
  ["Cream Corn Soup (Perfect)"] = 'png',
["Cream Corn Soup"] = 'png',
  ["Cream Corn Soup"] = 'png',
["Cream"] = 'png',
  ["Cream"] = 'png',
["Crate of Food"] = 'png',
  ["Crate of Food"] = 'png',
["Crate of Basic Supplies"] = 'png',
  ["Crate of Basic Supplies"] = 'png',
["Crab (Perfect)"] = 'png',
  ["Crab (Perfect)"] = 'png',
["Cooking Apron"] = 'png',
  ["Cooking Apron"] = 'png',
["Chicken Soup (Perfect)"] = 'png',
  ["Chicken Soup (Perfect)"] = 'png',
["Chicken Soup"] = 'png',
  ["Chicken Soup"] = 'png',
["Chicken (Perfect)"] = 'png',
  ["Chicken (Perfect)"] = 'png',
["Chest of Gems"] = 'png',
  ["Chest of Gems"] = 'png',
["Cherry Seeds"] = 'png',
  ["Cherry Seeds"] = 'png',
["Cherry Cupcake (Perfect)"] = 'png',
  ["Cherry Cupcake (Perfect)"] = 'png',
["Cherry Cupcake"] = 'png',
  ["Cherry Cupcake"] = 'png',
["Cherry"] = 'png',
  ["Cherry"] = 'png',
["Chef's Spoon"] = 'png',
  ["Chef's Spoon"] = 'png',
["Chef's Hat"] = 'png',
  ["Chef's Hat"] = 'png',
["Cheese"] = 'png',
  ["Cheese"] = 'png',
["Cave Giant Boots"] = 'png',
  ["Cave Giant Boots"] = 'png',
["Cave Fish (Perfect)"] = 'png',
  ["Cave Fish (Perfect)"] = 'png',
["Carrot Cake (Perfect)"] = 'png',
  ["Carrot Cake (Perfect)"] = 'png',
["Carrot Cake"] = 'png',
  ["Carrot Cake"] = 'png',
["Carp (Perfect)"] = 'png',
  ["Carp (Perfect)"] = 'png',
["Bread (Perfect)"] = 'png',
  ["Bread (Perfect)"] = 'png',
["Bread"] = 'png',
  ["Bread"] = 'png',
["Book of Scholars"] = 'png',
  ["Book of Scholars"] = 'png',
["Bob's Gloves"] = 'png',
  ["Bob's Gloves"] = 'png',
["Beef Pie (Perfect)"] = 'png',
  ["Beef Pie (Perfect)"] = 'png',
["Beef Pie"] = 'png',
  ["Beef Pie"] = 'png',
["Beef (Perfect)"] = 'png',
  ["Beef (Perfect)"] = 'png',
["Beef"] = 'png',
  ["Beef"] = 'png',
["Basic Soup (Perfect)"] = 'png',
  ["Basic Soup (Perfect)"] = 'png',
["Basic Soup"] = 'png',
  ["Basic Soup"] = 'png',
["Basic Bag"] = 'png',
  ["Basic Bag"] = 'png',
["Bag of Flour"] = 'png',
  ["Bag of Flour"] = 'png',
["Apple Tree Seeds"] = 'png',
  ["Apple Tree Seeds"] = 'png',
["Apple Pie (Perfect)"] = 'png',
  ["Apple Pie (Perfect)"] = 'png',
["Apple Pie"] = 'png',
  ["Apple Pie"] = 'png',
["Apple"] = 'png',
  ["Apple"] = 'png',
["Antique Vase"] = 'png',
  ["Antique Vase"] = 'png',
["Anglerfish (Perfect)"] = 'png',
  ["Anglerfish (Perfect)"] = 'png',
["Amulet of Incantation"] = 'png',
  ["Amulet of Incantation"] = 'png',
["Alchemist's Bag"] = 'png',
  ["Alchemist's Bag"] = 'png',
["Absorbing Shield"] = 'png',
  ["Absorbing Shield"] = 'png',
["Shield of Melee Power"] = 'png',
  ["Shield of Melee Power"] = 'png',
["Shield of Ranged Power"] = 'png',
  ["Shield of Ranged Power"] = 'png',
["Shield of Magic Power"] = 'png',
  ["Shield of Magic Power"] = 'png',
["Ring of Power"] = 'png',
  ["Ring of Power"] = 'png',
["Beginning of the End"] = 'png',
  ["Beginning of the End"] = 'png',
["Goo"] = 'png',
  ["Goo"] = 'png',
["Wildflower"] = 'png',
  ["Wildflower"] = 'png',
["Nature's Call Staff Top"] = 'png',
  ["Nature's Call Staff Top"] = 'png',
["Nature's Call Staff Bottom"] = 'png',
  ["Nature's Call Staff Bottom"] = 'png',
["Fine Poison Powder"] = 'png',
  ["Fine Poison Powder"] = 'png',
["Poison Scales"] = 'png',
  ["Poison Scales"] = 'png',
["Miolite Spore"] = 'png',
  ["Miolite Spore"] = 'png',
["Poison Essence"] = 'png',
  ["Poison Essence"] = 'png',
["Worm Spike"] = 'png',
  ["Worm Spike"] = 'png',
["Burning Essence"] = 'png',
  ["Burning Essence"] = 'png',
["Cursed Hands"] = 'png',
  ["Cursed Hands"] = 'png',
["Stinging Essence"] = 'png',
  ["Stinging Essence"] = 'png',
["Tough Shell"] = 'png',
  ["Tough Shell"] = 'png',
["Undead Essence"] = 'png',
  ["Undead Essence"] = 'png',
["Desecrated Bones"] = 'png',
  ["Desecrated Bones"] = 'png',
["War Axe"] = 'png',
  ["War Axe"] = 'png',
["Warberd"] = 'png',
  ["Warberd"] = 'png',
["Throwing Power Gloves"] = 'png',
  ["Throwing Power Gloves"] = 'png',
["Slingshot"] = 'png',
  ["Slingshot"] = 'png',
["Elerine Longbow"] = 'png',
  ["Elerine Longbow"] = 'png',
["Elerine Spear"] = 'png',
  ["Elerine Spear"] = 'png',
["Nature's Call Staff"] = 'png',
  ["Nature's Call Staff"] = 'png',
["Nature's Wrath Staff"] = 'png',
  ["Nature's Wrath Staff"] = 'png',
["Nature's Blessing Ring"] = 'png',
  ["Nature's Blessing Ring"] = 'png',
["Poisoned Shortbow"] = 'png',
  ["Poisoned Shortbow"] = 'png',
["Poisoned Dagger"] = 'png',
  ["Poisoned Dagger"] = 'png',
["Scaled Shield"] = 'png',
  ["Scaled Shield"] = 'png',
["Poison Virulence Ring"] = 'png',
  ["Poison Virulence Ring"] = 'png',
["Poison Virulence Gloves"] = 'png',
  ["Poison Virulence Gloves"] = 'png',
["Burning Madness Ring"] = 'png',
  ["Burning Madness Ring"] = 'png',
["Burning Madness Gloves"] = 'png',
  ["Burning Madness Gloves"] = 'png',
["Spiked Shell Ring"] = 'png',
  ["Spiked Shell Ring"] = 'png',
["Spiked Shell Gloves"] = 'png',
  ["Spiked Shell Gloves"] = 'png',
["Relentless Fury Ring"] = 'png',
  ["Relentless Fury Ring"] = 'png',
["Relentless Fury Gloves"] = 'png',
  ["Relentless Fury Gloves"] = 'png',
["Ring of Blade Echoes"] = 'png',
  ["Ring of Blade Echoes"] = 'png',
["Ring of Barrage"] = 'png',
  ["Ring of Barrage"] = 'png',
["Ring of Spirit Power"] = 'png',
  ["Ring of Spirit Power"] = 'png',
["Hinder Potion I"] = 'png',
  ["Hinder Potion I"] = 'png',
["Hinder Potion II"] = 'png',
  ["Hinder Potion II"] = 'png',
["Hinder Potion III"] = 'png',
  ["Hinder Potion III"] = 'png',
["Hinder Potion IV"] = 'png',
  ["Hinder Potion IV"] = 'png',
["Famished Potion I"] = 'png',
  ["Famished Potion I"] = 'png',
["Famished Potion II"] = 'png',
  ["Famished Potion II"] = 'png',
["Famished Potion III"] = 'png',
  ["Famished Potion III"] = 'png',
["Famished Potion IV"] = 'png',
  ["Famished Potion IV"] = 'png',
["Lethal Toxins Potion I"] = 'png',
  ["Lethal Toxins Potion I"] = 'png',
["Lethal Toxins Potion II"] = 'png',
  ["Lethal Toxins Potion II"] = 'png',
["Lethal Toxins Potion III"] = 'png',
  ["Lethal Toxins Potion III"] = 'png',
["Lethal Toxins Potion IV"] = 'png',
  ["Lethal Toxins Potion IV"] = 'png',
["Impending Darkness"] = 'png',
  ["Impending Darkness"] = 'png',
["Mastery Token (Astrology)"] = 'png',
  ["Mastery Token Astrology"] = 'png',
["Stardust"] = 'png',
  ["Stardust"] = 'png',
["Golden Stardust"] = 'png',
  ["Golden Stardust"] = 'png',
["Astrology Skillcape"] = 'png',
  ["Astrology Skillcape"] = 'png',
["Secret Stardust Potion I"] = 'png',
  ["Secret Stardust Potion I"] = 'png',
["Secret Stardust Potion II"] = 'png',
  ["Secret Stardust Potion II"] = 'png',
["Secret Stardust Potion III"] = 'png',
  ["Secret Stardust Potion III"] = 'png',
["Secret Stardust Potion IV"] = 'png',
  ["Secret Stardust Potion IV"] = 'png',
["Noxious Serpent"] = 'png',
  ["Noxious Serpent"] = 'png',
["Venomous Snake"] = 'png',
  ["Venomous Snake"] = 'png',
["Legaran Wurm"] = 'png',
  ["Legaran Wurm"] = 'png',
["Spiked Red Claw"] = 'png',
  ["Spiked Red Claw"] = 'png',
["Greater Skeletal Dragon"] = 'png',
  ["Greater Skeletal Dragon"] = 'png',
["Giant Moth"] = 'png',
  ["Giant Moth"] = 'png',
["Elerine Mage"] = 'png',
  ["Elerine Mage"] = 'png',
["Elerine Warrior"] = 'png',
  ["Elerine Warrior"] = 'png',
["Elerine Archer"] = 'png',
  ["Elerine Archer"] = 'png',
["Cursed Lich"] = 'png',
  ["Cursed Lich"] = 'png',
["Christmas Present (Blue)"] = 'png',
["Christmas Present (Green)"] = 'png',
["Christmas Present (Purple)"] = 'png',
["Christmas Present (Standard)"] = 'png',
["Christmas Present (White)"] = 'png',
["Christmas Present (Yellow)"] = 'png',
["Edible Candy Cane"] = 'png',
["Event Token (Holiday 2021)"] = 'png',
["Gingerbread House"] = 'png',
["Gingerbread Man"] = 'png',
["Holiday Scarf"] = 'png',
["Locked Chest"] = 'png',
["Locked Chest Key"] = 'png',
["Festive Chio"] = 'png',
["Festive Cool Rock"] = 'png',
["Mastery Tokens"] = 'gif',
["Enchanted Topaz Bolts"] = 'png',
["Enchanted Sapphire Bolts"] = 'png',
["Enchanted Ruby Bolts"] = 'png',
["Enchanted Emerald Bolts"] = 'png',
["Enchanted Diamond Bolts"] = 'png',
["Enchanted Jadestone Bolts"] = 'png',
["Poison Ring"] = 'png',
["Burning Ring"] = 'png',
["Frostburn Ring"] = 'png',
["Ultima Godsword"] = 'png',
["Mystery Wand"] = 'png',
["Poison Arrows"] = 'png',
["Fire Arrows"] = 'png',
["Frostburn Arrows"] = 'png',
["Burning Wand"] = 'png',
["Frostburn Wand"] = 'png',
["Ring of Balance"] = 'png',
["Flying Cape"] = 'png',
["Amulet of Healing"] = 'png',
["Sword of Some Reliability"] = 'png',
["One Layer Shield"] = 'png',
["Warding Shield"] = 'png',
["Tilted Crossbow"] = 'png',
["Ultimate Speed Boots"] = 'png',
["Almighty Ring"] = 'png',
["Punching Bag Platebody"] = 'png',
["Precision Gloves"] = 'png',
["Heavy Gloves"] = 'png',
["Ultimate Slapping Gloves"] = 'png',
["Amulet of Burning Leech"] = 'png',
["Amulet of Poison Leech"] = 'png',
["Magic Critical Amulet"] = 'png',
["Melee Critical Amulet"] = 'png',
["Bloodthirst Amulet"] = 'png',
["Dragon Head Helmet"] = 'png',
["Stonewall Shield"] = 'png',
["Impossible Longbow"] = 'png',
["Throwing Dragon Sword"] = 'png',
["Golbin Crate"] = 'png',
["Bone"] = 'png'
}
}


Line 227: Line 287:
--When calling for an icon of type Key, instead use type Value
--When calling for an icon of type Key, instead use type Value
local typeOverrides = {
local typeOverrides = {
  ['combat'] = 'combatArea',
['combat'] = 'combatArea',
  ['slayer'] = 'combatArea',
['slayer'] = 'combatArea',
}
}
--When calling for an icon for Key, replace with image Value, and optionally override type also
--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',
  ['Alt. Magic'] = 'Magic',
['Alt. Magic'] = 'Magic',
  ['Alternative Magic'] = 'Magic',
['Alternative Magic'] = 'Magic',
  ['Melee'] = 'Combat',
['Item Alchemy'] = {'Item Alchemy III', 'spell'},
  ['Spider (lv. 51)'] = 'Spider',
['Superheat'] = {'Superheat IV', 'spell'},
  ['Spider (lv. 52)'] = 'Brown Spider',
['Melee'] = 'Combat',
  ['Basic Resupply'] = 'Lobster',
['Spider (lv. 51)'] = 'Spider',
  ['Standard Resupply'] = 'Crab',
['Spider (lv. 52)'] = 'Brown Spider',
  ['Generous Resupply'] = 'Shark',
['Basic Resupply'] = {'Lobster', 'item'},
  ['Cooking Upgrade 1'] = {'Cooking', 'skill'},
['Standard Resupply'] = {'Crab', 'item'},
  ['Cooking Upgrade 2'] = {'Cooking', 'skill'}
['Generous Resupply'] = {'Shark', 'item'},
['Cooking Upgrade 1'] = {'Cooking', 'skill'},
['Cooking Upgrade 2'] = {'Cooking', 'skill'},
['Loot Container Stacking'] = {'Amulet of Looting', 'item'},
['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'},
-- Overrides that allow generic potion pages to be linked to easily
['Melee Accuracy Potion'] = {'Melee Accuracy Potion I', 'item'},
['Melee Evasion Potion'] = {'Melee Evasion Potion I', 'item'},
['Ranged Assistance Potion'] = {'Ranged Assistance Potion I', 'item'},
['Hinder Potion'] = {'Hinder Potion I', 'item'},
['Magic Assistance Potion'] = {'Magic Assistance Potion I', 'item'},
['Regeneration Potion'] = {'Regeneration Potion I', 'item'},
['Famished Potion'] = {'Famished Potion I', 'item'},
['Ranged Strength Potion'] = {'Ranged Strength Potion I', 'item'},
['Lucky Herb Potion'] = {'Lucky Herb Potion I', 'item'},
['Divine Potion'] = {'Divine Potion I', 'item'},
['Melee Strength Potion'] = {'Melee Strength Potion I', 'item'},
['Magic Damage Potion'] = {'Magic Damage Potion I', 'item'},
['Lethal Toxins Potion'] = {'Lethal Toxins Potion I', 'item'},
['Diamond Luck Potion'] = {'Diamond Luck Potion I', 'item'},
['Damage Reduction Potion'] = {'Damage Reduction Potion I', 'item'},
['Bird Nest Potion'] = {'Bird Nest Potion I', 'item'},
['Controlled Heat Potion'] = {'Controlled Heat Potion I', 'item'},
['Generous Cook Potion'] = {'Generous Cook Potion I', 'item'},
['Fishermans Potion'] = {'Fishermans Potion I', 'item'},
['Skilled Fletching Potion'] = {'Skilled Fletching Potion I', 'item'},
['Gentle Hands Potion'] = {'Gentle Hands Potion I', 'item'},
['Secret Stardust Potion'] = {'Secret Stardust Potion I', 'item'},
['Crafting Potion'] = {'Crafting Potion I', 'item'},
['Perfect Swing Potion'] = {'Perfect Swing Potion I', 'item'},
['Necromancer Potion'] = {'Necromancer Potion I', 'item'},
['Performance Enhancing Potion'] = {'Performance Enhancing Potion I', 'item'},
['Elemental Potion'] = {'Elemental Potion I', 'item'},
['Herblore Potion'] = {'Herblore Potion I', 'item'},
['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'},
['Seeing Gold Potion'] = {'Seeing Gold Potion I', '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
local linkOverrides = {
local linkOverrides = {
  ['Alt Magic'] = 'Alternative Magic',
['Alt Magic'] = 'Alternative Magic',
  ['Alt. Magic'] = 'Alternative Magic',
['Alt. Magic'] = 'Alternative Magic',
  ['Spider2'] = 'Brown Spider'
['Spider2'] = 'Brown Spider',
["Deedree"] = 'Astrology#Constellations',
["Iridan"] = 'Astrology#Constellations',
["Ameria"] = 'Astrology#Constellations',
["Terra"] = 'Astrology#Constellations',
["Vale"] = 'Astrology#Constellations',
["Syllia"] = 'Astrology#Constellations',
["Arachi"] = 'Astrology#Constellations',
["Ko"] = 'Astrology#Constellations',
["Tellus"] = 'Astrology#Constellations',
["Hyden"] = 'Astrology#Constellations',
["Qimican"] = 'Astrology#Constellations'
}
}
--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 = {
  ['Spider2'] = 'Brown Spider'
['Spider2'] = 'Brown Spider'
}
}
--Ambiguous overrides section
--Ambiguous overrides section
local ambiguousOverrides = {'Golbin', 'Chick', 'Chicken', 'Cyclops', 'Wizard'}
local ambiguousOverrides = {
['Golbin'] = true,
['Chick'] = true,
['Chicken'] = true,
['Cyclops'] = true,
['Wizard'] = true
}


local Shared= require("Module:Shared")
function p.Icon(frame)
local args = frame.args ~= nil and frame.args or frame
local link = args[1]
local text = args[2]
local iconType = args.type
local ext = args.ext ~= nil and args.ext ~= '' and args.ext or 'svg'
local notext = args.notext ~= nil and args.notext ~= ''
local nolink = args.nolink ~= nil and args.nolink ~= ''
local noicon = args.noicon ~= nil and args.noicon ~= ''
local menu = args.menu ~= nil and args.menu ~= ''
local imgSize = args.size ~= nil and args.size or 25
local qty = args.qty
local img = args.img ~= nil and args.img ~= '' and args.img or link


function p.Icon(frame)
link = fixPagename(link)
  local args = frame.args ~= nil and frame.args or frame
img = fixPagename(img)
  local link = args[1]
  local text = args[2]
  local iconType = args.type
  local ext = args.ext ~= nil and args.ext or 'svg'
  local notext = args.notext ~= nil and args.notext ~= ''
  local nolink = args.nolink ~= nil and args.nolink ~= ''
  local noicon = args.noicon ~= nil and args.noicon ~= ''
  local menu = args.menu ~= nil and args.menu ~= ''
  local imgSize = args.size ~= nil and args.size or 25
  local qty = args.qty
  local img = args.img ~= nil and args.img or link


  link = Shared.fixPagename(link)
img = sgsub(img, '#', '')
  img = Shared.fixPagename(img)
img = sgsub(img, '/Training', '')
img = sgsub(img, '/Guide', '')
link = sgsub(link, '#', '')


  img = string.gsub(img, '#', '')
--MANUAL OVERRIDES
  link = string.gsub(link, '#', '')
local ovrImg = imgOverrides[link]
  --MANUAL OVERRIDES
local ovrTxt = txtOverrides[link]
  if imgOverrides[link] ~= nil and img == link then
local ovrLink = linkOverrides[link]
  local ovr = imgOverrides[link]
local hasText = (text ~= nil and text ~= '')
  if type(ovr) == 'string' then
if ovrImg ~= nil and img == link then
  img = imgOverrides[link]
if type(ovrImg) == 'string' then
elseif type(ovr) == 'table' then
img = ovrImg
  img = ovr[1]
elseif type(ovrImg) == 'table' then
  if ovr[2] ~= nil then iconType = ovr[2] end
img = ovrImg[1]
if ovrImg[2] ~= nil then iconType = ovrImg[2] end
end
end
-- 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 ovrExt = extOverrides[img]
local ovrType = typeOverrides[iconType]
if not hasText and ovrTxt ~= nil then
text = ovrTxt
hasText = true
end
if ovrLink ~= nil then
if not hasText then
text = link
hasText = true
end
link = ovrLink
end
if ovrTypeExt ~= nil then
ext = ovrTypeExt
elseif ovrExt ~= nil then
ext = ovrExt
elseif iconType == 'mark' then
ext = 'png'
end
if ovrType ~= nil then
iconType = ovrType
end
-- There are a couple specific double overrides to be included that don't fit in the above lists
if ambiguousOverrides[link] then
if not hasText then
text = link
hasText = true
end
link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')'
end
end
  end
  if text == nil and txtOverrides[link] ~= nil then
    text = txtOverrides[link]
  end
  if linkOverrides[link] ~= nil then
    if text == nil then text = link end
    link = linkOverrides[link]
  end
  if typeExtOverrides[iconType] ~= nil and typeExtOverrides[iconType][img] ~= nil then
  ext = typeExtOverrides[iconType][img]
  elseif extOverrides[img] ~= nil then
    ext = extOverrides[img]
  elseif iconType == 'mark' then
    ext = 'png'
  end
  if typeOverrides[iconType] ~= nil then
    iconType = typeOverrides[iconType]
  end
  --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 text == nil then text = link end
    link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')'
  end


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


  if not notext then
if not notext then
  -- If the result is currently empty then there's no need to pad with whitespace
if nolink then
  local padStr = (string.len(result) > 0 and ' ' or '')
resultText = resultText .. (noicon and '' or ' ') .. (hasText and text or link)
    if nolink then
else
      if text ~= nil and text ~= '' then
resultText = resultText .. (noicon and '' or ' ') .. '[[' .. link .. (hasText and text ~= link and '|' .. text or '') .. ']]'
        result = result..padStr..text
end
      else
end
        result = result..padStr..link
      end
    else
      result = result..padStr..'[['..link
      if text ~= nil and text ~= '' and text ~= link then
        result = result..'|'..text
      end
      result = result..']]'
    end
  end
 
  if not noicon then
    result = '<span style="display:inline-block">'..result..'</span>'
  end


  if menu then
-- Add Quantity to the front if requested
    result = '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|'..result
--local resultQty = (qty ~= nil and qty ~= '' and formatnum(qty) .. ' ' or '')
    result = result..'\r\n|}'
if qty ~= nil and qty ~= '' then
  end
resultText = formatnum(qty) .. ' ' .. resultText
end


  return result
if menu then
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}'
elseif not noicon then
return '<span style="display:inline-block">' .. resultText .. '</span>'
else
return resultText
end
end
end


Line 365: Line 487:


function p._SkillReq(skill, level, showText)
function p._SkillReq(skill, level, showText)
  local result = p.Icon({skill, type='skill', notext='true'})
local result = p.Icon({skill, type='skill', notext='true'})
  if showText then
if showText then
    result = result..' [['..skill..']]'
result = result..' [['..skill..']]'
  end
end
  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


  result = '<span style="display:inline-block">'..result..'</span>'
result = '<span style="display:inline-block">'..result..'</span>'
  return result
return result
end
end


function p.SkillReq(frame)
function p.SkillReq(frame)
  local args = frame.args ~= nil and frame.args or frame
local args = frame.args ~= nil and frame.args or frame
  local skill = args[1]
local skill = args[1]
  local level = tonumber(args[2])
local level = tonumber(args[2])
  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
end


function p._MasteryReq(itemName, level, showText)
function p._MasteryReq(itemName, level, showText)
  local iconname = itemName
local iconname = itemName
  local linkname = itemName
local linkname = itemName
  --First, go with the lowest tier of potions if a potion is mentioned
--First, go with the lowest tier of potions if a potion is mentioned
  local s, e = string.find(itemName, 'Potion')
local s, e = string.find(itemName, 'Potion')
  if e ~= nil then
if e ~= nil then
    linkname = string.sub(itemName, 1, e)
linkname = string.sub(itemName, 1, e)
    iconname = linkname..' I'
iconname = linkname..' I'
  end
end


  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})..p.Icon({'Mastery', notext=true})
  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>'
  return result
return result
end
end


function p.MasteryReq(frame)
function p.MasteryReq(frame)
  local args = frame.args ~= nil and frame.args or frame
local args = frame.args ~= nil and frame.args or frame
  local itemName = args[1]
local itemName = args[1]
  local level = tonumber(args[2])
local level = tonumber(args[2])
  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
end


function p._Currency(fileName, link, amt, maxAmt)
function p._Currency(fileName, link, amt, maxAmt)
  local amtText = Shared.formatnum(amt)
local amtText = formatnum(amt)
  if maxAmt ~= nil and maxAmt >= amt then
if maxAmt ~= nil and maxAmt >= amt then
    amtText = amtText .. ' - ' .. Shared.formatnum(maxAmt)
amtText = amtText .. ' - ' .. formatnum(maxAmt)
  end
end


  local fileText = ''
local fileText = ''
  if fileName ~= nil then
if fileName ~= nil then
    fileText = '[[File:' .. fileName .. '|25px'
fileText = '[[File:' .. fileName .. '|25px'
    if link ~= nil then
if link ~= nil then
      fileText = fileText .. '|link=' .. link
fileText = fileText .. '|link=' .. link
    end
end
    fileText = fileText .. ']]&nbsp;'
fileText = fileText .. ']]&nbsp;'
  end
end


  return '<span style="display:inline-block">' .. fileText .. amtText .. '</span>'
return '<span style="display:inline-block">' .. fileText .. amtText .. '</span>'
end
end


function p.GP(amt, maxamt)
function p.GP(amt, maxamt)
  return p._Currency('Coins.svg', 'Coins', amt, maxamt)
return p._Currency('Coins.svg', 'Coins', 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', 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', amt, maxamt)
end
end


return p
return p

Revision as of 21:06, 2 May 2022

Documentation for this module may be created at Module:Icons/doc

--You can't generate Templates from within Lua due to the loading order, so instead copying the Icon functionality into a module so it can be pulled elsewhere.
--Should function very similarly to how Template:Icon works

local Shared = require("Module:Shared")

-- Locally index some functions for performance
local sgsub, fixPagename, formatnum, tostring, type = string.gsub, Shared.fixPagename, Shared.formatnum, tostring, type

local p = {}
--Extension overrides for items that have non-svg images
local extOverrides = {
	["Adventure"] = "png",
	["Crown of Rhaelyx"] = "png",
	["Jewel of Rhaelyx"] = "png",
	["Circlet of Rhaelyx"] = "png",
	["Charge Stone of Rhaelyx"] = "png",
	["Mysterious Stone"] = "png",
	["Lemon"] = "jpg",
	["Lemons"] = "jpg",
	["Lemonade"] = "jpg",
	["Miolite Sprig"] = "png",
	["Miolite Trio"] = "png",
	["Miolite Warden"] = "png",
	["Miolite Monarch"] = "png",
	["Wicked Greater Dragon"] = "png",
	["Hunting Greater Dragon"] = "png",
	["Chaotic Greater Dragon"] = "png",
	["Beavis"] = "png",
	["Pudding Duckie"] = "png",
	["Pyro"] = "png",
	["Snek"] = "png",
	["Larry, the Lonely Lizard"] = "png",
	["Caaarrrlll"] = "png",
	["Gronk"] = "png",
	["Finn, the Cat"] = "png",
	["Marahute"] = "png",
	["Monk-ey"] = "png",
	["Asura"] = "png",
	["Summoning Shard (Silver)"] = "png",
	["Summoning Shard (Red)"] = "png",
	["Summoning Shard (Green)"] = "png",
	["Summoning Shard (Gold)"] = "png",
	["Summoning Shard (Blue)"] = "png",
	["Summoning Shard (Black)"] = "png",
	['Infernal Core'] = 'png',
	['Cool Glasses'] = 'png',
	["Wizard's Sigil"] = 'png',
	["Wizard's Scroll"] = 'png',
	["Whetstone"] = 'png',
	["Whale (Perfect)"] = 'png',
	["Trout (Perfect)"] = 'png',
	["Training Shield"] = 'png',
	["Thiever's Cape"] = 'png',
	["Thief's Moneysack"] = 'png',
	["Swordfish (Perfect)"] = 'png',
	["Strawberry Cupcake (Perfect)"] = 'png',
	["Strawberry Cupcake"] = 'png',
	["Strawberry Cake (Perfect)"] = 'png',
	["Strawberry Cake"] = 'png',
	["Stack of Bones"] = 'png',
	["Sneak-Ers"] = 'png',
	["Shrimp (Perfect)"] = 'png',
	["Shipwheel"] = 'png',
	["Shark (Perfect)"] = 'png',
	["Seed Pouch"] = 'png',
	["Seahorse (Perfect)"] = 'png',
	["Sardine (Perfect)"] = 'png',
	["Salmon (Perfect)"] = 'png',
	["Sailor's Top"] = 'png',
	["Runecrafting Pouch"] = 'png',
	["Ring of Wealth"] = 'png',
	["Raw Chicken"] = 'png',
	["Raw Beef"] = 'png',
	["Prayer Scroll"] = 'png',
	["Plain Pizza Slice (Perfect)"] = 'png',
	["Plain Pizza Slice"] = 'png',
	["Pile of Ores"] = 'png',
	["Pile of Logs"] = 'png',
	["Miner's Helmet"] = 'png',
	["Merchant's Permit"] = 'png',
	["Meat Pizza Slice (Perfect)"] = 'png',
	["Meat Pizza Slice"] = 'png',
	["Marksman's Sigil"] = 'png',
	["Manta Ray (Perfect)"] = 'png',
	["Lumberjack's Top"] = 'png',
	["Lobster (Perfect)"] = 'png',
	["Lemon Cake (Perfect)"] = 'png',
	["Lemon Cake"] = 'png',
	["Knight's Sigil"] = 'png',
	["Knight's Defender"] = 'png',
	["Knight's Cape"] = 'png',
	["Jeweled Necklace"] = 'png',
	["Jester's Hat"] = 'png',
	["Jadestone"] = 'png',
	["Herring (Perfect)"] = 'png',
	["Hearty Soup (Perfect)"] = 'png',
	["Hearty Soup"] = 'png',
	["Gold Crested Shield"] = 'png',
	["Golbin Mask"] = 'png',
	["Giant Club"] = 'png',
	["Fishing Hook"] = 'png',
	["Fine Coinpurse"] = 'png',
	["Fanfish (Perfect)"] = 'png',
	["Cream Corn Soup (Perfect)"] = 'png',
	["Cream Corn Soup"] = 'png',
	["Cream"] = 'png',
	["Crate of Food"] = 'png',
	["Crate of Basic Supplies"] = 'png',
	["Crab (Perfect)"] = 'png',
	["Cooking Apron"] = 'png',
	["Chicken Soup (Perfect)"] = 'png',
	["Chicken Soup"] = 'png',
	["Chicken (Perfect)"] = 'png',
	["Chest of Gems"] = 'png',
	["Cherry Seeds"] = 'png',
	["Cherry Cupcake (Perfect)"] = 'png',
	["Cherry Cupcake"] = 'png',
	["Cherry"] = 'png',
	["Chef's Spoon"] = 'png',
	["Chef's Hat"] = 'png',
	["Cheese"] = 'png',
	["Cave Giant Boots"] = 'png',
	["Cave Fish (Perfect)"] = 'png',
	["Carrot Cake (Perfect)"] = 'png',
	["Carrot Cake"] = 'png',
	["Carp (Perfect)"] = 'png',
	["Bread (Perfect)"] = 'png',
	["Bread"] = 'png',
	["Book of Scholars"] = 'png',
	["Bob's Gloves"] = 'png',
	["Beef Pie (Perfect)"] = 'png',
	["Beef Pie"] = 'png',
	["Beef (Perfect)"] = 'png',
	["Beef"] = 'png',
	["Basic Soup (Perfect)"] = 'png',
	["Basic Soup"] = 'png',
	["Basic Bag"] = 'png',
	["Bag of Flour"] = 'png',
	["Apple Tree Seeds"] = 'png',
	["Apple Pie (Perfect)"] = 'png',
	["Apple Pie"] = 'png',
	["Apple"] = 'png',
	["Antique Vase"] = 'png',
	["Anglerfish (Perfect)"] = 'png',
	["Amulet of Incantation"] = 'png',
	["Alchemist's Bag"] = 'png',
	["Absorbing Shield"] = 'png',
	["Shield of Melee Power"] = 'png',
	["Shield of Ranged Power"] = 'png',
	["Shield of Magic Power"] = 'png',
	["Ring of Power"] = 'png',
	["Beginning of the End"] = 'png',
	["Goo"] = 'png',
	["Wildflower"] = 'png',
	["Nature's Call Staff Top"] = 'png',
	["Nature's Call Staff Bottom"] = 'png',
	["Fine Poison Powder"] = 'png',
	["Poison Scales"] = 'png',
	["Miolite Spore"] = 'png',
	["Poison Essence"] = 'png',
	["Worm Spike"] = 'png',
	["Burning Essence"] = 'png',
	["Cursed Hands"] = 'png',
	["Stinging Essence"] = 'png',
	["Tough Shell"] = 'png',
	["Undead Essence"] = 'png',
	["Desecrated Bones"] = 'png',
	["War Axe"] = 'png',
	["Warberd"] = 'png',
	["Throwing Power Gloves"] = 'png',
	["Slingshot"] = 'png',
	["Elerine Longbow"] = 'png',
	["Elerine Spear"] = 'png',
	["Nature's Call Staff"] = 'png',
	["Nature's Wrath Staff"] = 'png',
	["Nature's Blessing Ring"] = 'png',
	["Poisoned Shortbow"] = 'png',
	["Poisoned Dagger"] = 'png',
	["Scaled Shield"] = 'png',
	["Poison Virulence Ring"] = 'png',
	["Poison Virulence Gloves"] = 'png',
	["Burning Madness Ring"] = 'png',
	["Burning Madness Gloves"] = 'png',
	["Spiked Shell Ring"] = 'png',
	["Spiked Shell Gloves"] = 'png',
	["Relentless Fury Ring"] = 'png',
	["Relentless Fury Gloves"] = 'png',
	["Ring of Blade Echoes"] = 'png',
	["Ring of Barrage"] = 'png',
	["Ring of Spirit Power"] = 'png',
	["Hinder Potion I"] = 'png',
	["Hinder Potion II"] = 'png',
	["Hinder Potion III"] = 'png',
	["Hinder Potion IV"] = 'png',
	["Famished Potion I"] = 'png',
	["Famished Potion II"] = 'png',
	["Famished Potion III"] = 'png',
	["Famished Potion IV"] = 'png',
	["Lethal Toxins Potion I"] = 'png',
	["Lethal Toxins Potion II"] = 'png',
	["Lethal Toxins Potion III"] = 'png',
	["Lethal Toxins Potion IV"] = 'png',
	["Impending Darkness"] = 'png',
	["Mastery Token (Astrology)"] = 'png',
	["Stardust"] = 'png',
	["Golden Stardust"] = 'png',
	["Astrology Skillcape"] = 'png',
	["Secret Stardust Potion I"] = 'png',
	["Secret Stardust Potion II"] = 'png',
	["Secret Stardust Potion III"] = 'png',
	["Secret Stardust Potion IV"] = 'png',
	["Noxious Serpent"] = 'png',
	["Venomous Snake"] = 'png',
	["Legaran Wurm"] = 'png',
	["Spiked Red Claw"] = 'png',
	["Greater Skeletal Dragon"] = 'png',
	["Giant Moth"] = 'png',
	["Elerine Mage"] = 'png',
	["Elerine Warrior"] = 'png',
	["Elerine Archer"] = 'png',
	["Cursed Lich"] = 'png',
	["Christmas Present (Blue)"] = 'png',
	["Christmas Present (Green)"] = 'png',
	["Christmas Present (Purple)"] = 'png',
	["Christmas Present (Standard)"] = 'png',
	["Christmas Present (White)"] = 'png',
	["Christmas Present (Yellow)"] = 'png',
	["Edible Candy Cane"] = 'png',
	["Event Token (Holiday 2021)"] = 'png',
	["Gingerbread House"] = 'png',
	["Gingerbread Man"] = 'png',
	["Holiday Scarf"] = 'png',
	["Locked Chest"] = 'png',
	["Locked Chest Key"] = 'png',
	["Festive Chio"] = 'png',
	["Festive Cool Rock"] = 'png',
	["Mastery Tokens"] = 'gif',
	["Enchanted Topaz Bolts"] = 'png',
	["Enchanted Sapphire Bolts"] = 'png',
	["Enchanted Ruby Bolts"] = 'png',
	["Enchanted Emerald Bolts"] = 'png',
	["Enchanted Diamond Bolts"] = 'png',
	["Enchanted Jadestone Bolts"] = 'png',
	["Poison Ring"] = 'png',
	["Burning Ring"] = 'png',
	["Frostburn Ring"] = 'png',
	["Ultima Godsword"] = 'png',
	["Mystery Wand"] = 'png',
	["Poison Arrows"] = 'png',
	["Fire Arrows"] = 'png',
	["Frostburn Arrows"] = 'png',
	["Burning Wand"] = 'png',
	["Frostburn Wand"] = 'png',
	["Ring of Balance"] = 'png',
	["Flying Cape"] = 'png',
	["Amulet of Healing"] = 'png',
	["Sword of Some Reliability"] = 'png',
	["One Layer Shield"] = 'png',
	["Warding Shield"] = 'png',
	["Tilted Crossbow"] = 'png',
	["Ultimate Speed Boots"] = 'png',
	["Almighty Ring"] = 'png',
	["Punching Bag Platebody"] = 'png',
	["Precision Gloves"] = 'png',
	["Heavy Gloves"] = 'png',
	["Ultimate Slapping Gloves"] = 'png',
	["Amulet of Burning Leech"] = 'png',
	["Amulet of Poison Leech"] = 'png',
	["Magic Critical Amulet"] = 'png',
	["Melee Critical Amulet"] = 'png',
	["Bloodthirst Amulet"] = 'png',
	["Dragon Head Helmet"] = 'png',
	["Stonewall Shield"] = 'png',
	["Impossible Longbow"] = 'png',
	["Throwing Dragon Sword"] = 'png',
	["Golbin Crate"] = 'png',
	["Bone"] = 'png'
}

--Some overrides only apply for a specific type
local typeExtOverrides = {
	['item'] = {
			['Chicken'] = '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, and optionally override type also
local imgOverrides = {
	['Alt Magic'] = 'Magic',
	['Alt. Magic'] = 'Magic',
	['Alternative Magic'] = 'Magic',
	['Item Alchemy'] = {'Item Alchemy III', 'spell'},
	['Superheat'] = {'Superheat IV', 'spell'},
	['Melee'] = 'Combat',
	['Spider (lv. 51)'] = 'Spider',
	['Spider (lv. 52)'] = 'Brown Spider',
	['Basic Resupply'] = {'Lobster', 'item'},
	['Standard Resupply'] = {'Crab', 'item'},
	['Generous Resupply'] = {'Shark', 'item'},
	['Cooking Upgrade 1'] = {'Cooking', 'skill'},
	['Cooking Upgrade 2'] = {'Cooking', 'skill'},
	['Loot Container Stacking'] = {'Amulet of Looting', 'item'},
	['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'},
	-- Overrides that allow generic potion pages to be linked to easily
	['Melee Accuracy Potion'] = {'Melee Accuracy Potion I', 'item'},
	['Melee Evasion Potion'] = {'Melee Evasion Potion I', 'item'},
	['Ranged Assistance Potion'] = {'Ranged Assistance Potion I', 'item'},
	['Hinder Potion'] = {'Hinder Potion I', 'item'},
	['Magic Assistance Potion'] = {'Magic Assistance Potion I', 'item'},
	['Regeneration Potion'] = {'Regeneration Potion I', 'item'},
	['Famished Potion'] = {'Famished Potion I', 'item'},
	['Ranged Strength Potion'] = {'Ranged Strength Potion I', 'item'},
	['Lucky Herb Potion'] = {'Lucky Herb Potion I', 'item'},
	['Divine Potion'] = {'Divine Potion I', 'item'},
	['Melee Strength Potion'] = {'Melee Strength Potion I', 'item'},
	['Magic Damage Potion'] = {'Magic Damage Potion I', 'item'},
	['Lethal Toxins Potion'] = {'Lethal Toxins Potion I', 'item'},
	['Diamond Luck Potion'] = {'Diamond Luck Potion I', 'item'},
	['Damage Reduction Potion'] = {'Damage Reduction Potion I', 'item'},
	['Bird Nest Potion'] = {'Bird Nest Potion I', 'item'},
	['Controlled Heat Potion'] = {'Controlled Heat Potion I', 'item'},
	['Generous Cook Potion'] = {'Generous Cook Potion I', 'item'},
	['Fishermans Potion'] = {'Fishermans Potion I', 'item'},
	['Skilled Fletching Potion'] = {'Skilled Fletching Potion I', 'item'},
	['Gentle Hands Potion'] = {'Gentle Hands Potion I', 'item'},
	['Secret Stardust Potion'] = {'Secret Stardust Potion I', 'item'},
	['Crafting Potion'] = {'Crafting Potion I', 'item'},
	['Perfect Swing Potion'] = {'Perfect Swing Potion I', 'item'},
	['Necromancer Potion'] = {'Necromancer Potion I', 'item'},
	['Performance Enhancing Potion'] = {'Performance Enhancing Potion I', 'item'},
	['Elemental Potion'] = {'Elemental Potion I', 'item'},
	['Herblore Potion'] = {'Herblore Potion I', 'item'},
	['Generous Harvest Potion'] = {'Generous Harvest Potion I', 'item'},
	['Seeing Gold Potion'] = {'Seeing Gold Potion I', 'item'}
}
--When calling for an icon for Key, the link goes to Value
local linkOverrides = {
	['Alt Magic'] = 'Alternative Magic',
	['Alt. Magic'] = 'Alternative Magic',
	['Spider2'] = 'Brown Spider',
	["Deedree"] = 'Astrology#Constellations',
	["Iridan"] = 'Astrology#Constellations',
	["Ameria"] = 'Astrology#Constellations',
	["Terra"] = 'Astrology#Constellations',
	["Vale"] = 'Astrology#Constellations',
	["Syllia"] = 'Astrology#Constellations',
	["Arachi"] = 'Astrology#Constellations',
	["Ko"] = 'Astrology#Constellations',
	["Tellus"] = 'Astrology#Constellations',
	["Hyden"] = 'Astrology#Constellations',
	["Qimican"] = 'Astrology#Constellations'
}
--If no other text override was specified for the given link, use these
local txtOverrides = {
	['Spider2'] = 'Brown Spider'
}
--Ambiguous overrides section
local ambiguousOverrides = {
	['Golbin'] = true,
	['Chick'] = true,
	['Chicken'] = true,
	['Cyclops'] = true,
	['Wizard'] = true
}

function p.Icon(frame)
	local args = frame.args ~= nil and frame.args or frame
	local link = args[1]
	local text = args[2]
	local iconType = args.type
	local ext = args.ext ~= nil and args.ext ~= '' and args.ext or 'svg'
	local notext = args.notext ~= nil and args.notext ~= ''
	local nolink = args.nolink ~= nil and args.nolink ~= ''
	local noicon = args.noicon ~= nil and args.noicon ~= ''
	local menu = args.menu ~= nil and args.menu ~= ''
	local imgSize = args.size ~= nil and args.size or 25
	local qty = args.qty
	local img = args.img ~= nil and args.img ~= '' and args.img or link

	link = fixPagename(link)
	img = fixPagename(img)

	img = sgsub(img, '#', '')
	img = sgsub(img, '/Training', '')
	img = sgsub(img, '/Guide', '')
	link = sgsub(link, '#', '')

	--MANUAL OVERRIDES
	local ovrImg = imgOverrides[link]
	local ovrTxt = txtOverrides[link]
	local ovrLink = linkOverrides[link]
	local hasText = (text ~= nil and text ~= '')
	if ovrImg ~= nil and img == link then
		if type(ovrImg) == 'string' then
			img = ovrImg
		elseif type(ovrImg) == 'table' then
			img = ovrImg[1]
			if ovrImg[2] ~= nil then iconType = ovrImg[2] end
		end
	end
	-- 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 ovrExt = extOverrides[img]
	local ovrType = typeOverrides[iconType]
	if not hasText and ovrTxt ~= nil then
		text = ovrTxt
		hasText = true
	end
	if ovrLink ~= nil then
		if not hasText then
			text = link
			hasText = true
		end
		link = ovrLink
	end
	if ovrTypeExt ~= nil then
		ext = ovrTypeExt
	elseif ovrExt ~= nil then
		ext = ovrExt
	elseif iconType == 'mark' then
		ext = 'png'
	end
	if ovrType ~= nil then
		iconType = ovrType
	end
	-- There are a couple specific double overrides to be included that don't fit in the above lists
	if ambiguousOverrides[link] then
		if not hasText then
			text = link
			hasText = true
		end
		link = link..' ('..(iconType == 'mark' and 'item' or iconType)..')'
	end

	local resultText = ''
	if not noicon then
		-- Image size
		local txtSize = tostring(imgSize)
		-- Extension and type if one is set
		local txtImg = (iconType ~= nil and iconType ~= '' and img .. '_(' .. iconType .. ')' or img) .. '.' .. ext
		-- Include a link unless no link -and- no text was requested
		local txtLink = '|link=' .. (nolink and notext and '' or link)
		resultText = '[[File:' .. txtImg .. '|' .. txtSize .. 'x' .. txtSize .. 'px' .. txtLink .. ']]'
	end

	if not notext then
		if nolink then
			resultText = resultText .. (noicon and '' or ' ') .. (hasText and text or link)
		else
			resultText = resultText .. (noicon and '' or ' ') .. '[[' .. link .. (hasText and text ~= link and '|' .. text or '') .. ']]'
		end
	end

	-- Add Quantity to the front if requested
	--local resultQty = (qty ~= nil and qty ~= '' and formatnum(qty) .. ' ' or '')
	if qty ~= nil and qty ~= '' then
		resultText = formatnum(qty) .. ' ' .. resultText
	end

	if menu then
		return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. resultText .. '\r\n|}'
	elseif not noicon then
		return '<span style="display:inline-block">' .. resultText .. '</span>'
	else
		return resultText
	end
end

-- Wrapper for p.Icon(), uses the same parameters but forces noicon = true
function p.Link(frame)
	local args = frame.args ~= nil and frame.args or frame
	args.noicon = true
	return p.Icon({['args'] = args})
end

function p._SkillReq(skill, level, showText)
	local result = p.Icon({skill, type='skill', notext='true'})
	if showText then
		result = result..' [['..skill..']]'
	end
	if level == nil then level = 'Unknown [[Category:Pages with script errors]]' end
	result = result.." Level "..level

	result = '<span style="display:inline-block">'..result..'</span>'
	return result
end

function p.SkillReq(frame)
	local args = frame.args ~= nil and frame.args or frame
	local skill = args[1]
	local level = tonumber(args[2])
	local showText = args.showText ~= nil and args.showText ~= '' and args.showText ~= 'false'
	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

function p._Currency(fileName, link, amt, maxAmt)
	local amtText = formatnum(amt)
	if maxAmt ~= nil and maxAmt >= amt then
		amtText = amtText .. ' - ' .. formatnum(maxAmt)
	end

	local fileText = ''
	if fileName ~= nil then
		fileText = '[[File:' .. fileName .. '|25px'
		if link ~= nil then
			fileText = fileText .. '|link=' .. link
		end
		fileText = fileText .. ']]&nbsp;'
	end

	return '<span style="display:inline-block">' .. fileText .. amtText .. '</span>'
end

function p.GP(amt, maxamt)
	return p._Currency('Coins.svg', 'Coins', amt, maxamt)
end

function p.SC(amt, maxamt)
	return p._Currency('Slayer Coins.svg', 'Currency#Slayer Coins', amt, maxamt)
end

function p.RC(amt, maxamt)
	return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', amt, maxamt)
end

return p