Anonymous

Module:Icons: Difference between revisions

From Melvor Idle
Currency handling & icon override changes for v1.3
(getExpansionIcon: Implemented ItA expansion icon)
(Currency handling & icon override changes for v1.3)
Line 34: Line 34:
["Slayer Coins"] = "svg",
["Slayer Coins"] = "svg",
["Raid Coins"] = "svg",
["Raid Coins"] = "svg",
["Abyssal Pieces"] = "svg",
["Abyssal Slayer Coins"] = "svg",
["TotH"] = "svg",
["TotH"] = "svg",
["Shop"] = "svg",
["Shop"] = "svg",
Line 211: Line 213:
["Ritual Site"] = "png",
["Ritual Site"] = "png",
["Shipwreck Cove"] = "png",
["Shipwreck Cove"] = "png",
-- Slayer areas
["Blighted Reach"] = "png",
["Crimson Forest"] = "png",
["Echo Mire"] = "png",
["Eldritch Chasm"] = "png",
["Fractured Spires"] = "png",
["Paranoia Pit"] = "png",
["Petrified Lair"] = "png",
["Tangled Grove"] = "png",
["Tendril Hollow"] = "png",
["Toxic Wastes"] = "png",
["Void Enclave"] = "png",
["Void Nexus"] = "png",
["Whispering Sea"] = "png",
["Withering Catacombs"] = "png"
}
}
}
}
Line 217: Line 234:
local typeExtOverrides = {
local typeExtOverrides = {
-- Example: ["item"] = { ["Chicken"] = "png" }
-- Example: ["item"] = { ["Chicken"] = "png" }
["building"] = {
["Abyssal Combat Lab"] = "png",
["Abyssal Enhancer"] = "png",
["Abyssal Gateway"] = "png",
["Abyssal Harvester I"] = "png",
["Abyssal Harvester II"] = "png",
["Abyssal Harvester III"] = "png",
["Abyssal Research Lab"] = "png",
["Arcane Altar"] = "png",
["Armourer I"] = "png",
["Armourer II"] = "png",
["Armourer III"] = "png",
["Armourer IV"] = "png",
["Bonfire"] = "png",
["Divine Sanctuary"] = "png",
["Empowered Altar"] = "png",
["Enchanted Tower"] = "png",
["Ethereal Altar"] = "png",
["Ethereal Sanctuary"] = "png",
["Fire Pit"] = "png",
["Obsidian Blaster"] = "png",
["Obsidian Mines"] = "png",
["Obsidian Quarry"] = "png",
["Obsidian Walls"] = "png",
["Reinforced Carpenter I"] = "png",
["Reinforced Carpenter II"] = "png",
["Reinforced Carpenter III"] = "png",
["Runestone Combiner"] = "png",
["Runestone Crafter"] = "png",
["Runestone Merger"] = "png",
["Sanctuary"] = "png",
["Slayer Research Lab"] = "png",
["Stone Walls"] = "png",
["Void Sanctuary"] = "png",
["Voidfire Beacon"] = "png",
["Weaponsmith I"] = "png",
["Weaponsmith II"] = "png",
["Weaponsmith III"] = "png",
["Weaponsmith IV"] = "png",
["Wooden Walls"] = "png"
},
["combatArea"] = {
-- Combat areas
["Abyssal Farmlands"] = "png",
["Blighted Marsh"] = "png",
["Dark Descent"] = "png",
["Dreaded Crossing"] = "png",
["Eldritch Domain"] = "png",
["Fractured Plains"] = "png",
["Lightless Cave"] = "png",
["Murmuring Forest"] = "png",
["Smoggy Plain"] = "png",
["Void Conflux"] = "png",
["Whisperwind Cove"] = "png",
["Withering Bastion"] = "png",
},
["dungeon"] = {
["Into the Abyss"] = "png",
["The Abyssal Approach"] = "png"
},
["item"] = {
["item"] = {
-- These familiars also exist as type mark, where the image is of PNG format
-- These familiars also exist as type mark, where the image is of PNG format
Line 268: Line 345:
["Lava Golem"] = "svg",
["Lava Golem"] = "svg",
["Puppet Master"] = "svg"
["Puppet Master"] = "svg"
},
["prayer"] = {
-- ItA prayers
["Annihilation"] = "png",
["Brutality"] = "png",
["Cruelty"] = "png",
["Deadshot"] = "png",
["Devastation"] = "png",
["Dispersion"] = "png",
["Dissipation"] = "png",
["Drain"] = "png",
["Elusion"] = "png",
["Endure"] = "png",
["Evisceration"] = "png",
["Ferocity"] = "png",
["Focused"] = "png",
["Instability"] = "png",
["Magic Shroud"] = "png",
["Melee Shroud"] = "png",
["Menace"] = "png",
["Meticulous"] = "png",
["Obliteration"] = "png",
["Opress"] = "png",
["Piercer"] = "png",
["Ranged Shroud"] = "png",
["Ravage"] = "png",
["Renewal"] = "png",
["Savagery"] = "png",
["Siphon"] = "png",
["Terrorize"] = "png",
["Tyranny"] = "png",
["Unrelenting"] = "png",
["Vanish"] = "png",
["Volatility"] = "png"
},
["resource"] = {
-- Abyssal Township resources
["Obsidian"] = "png",
["Runestone"] = "png",
["Voidfire Ash"] = "png",
["Armour & Weaponry"] = "png",
["Abyssal Stone"] = "png",
["Abyssal Pieces"] = "png"
},
},
["rock"] = {
["rock"] = {
Line 276: Line 396:
["Cerulean"] = "png",
["Cerulean"] = "png",
["Crystal"] = "png",
["Crystal"] = "png",
["Pure Crystal"] = "png"
["Pure Crystal"] = "png",
["Abycite"] = "png",
["Abyssal Essence"] = "png",
["Abyssium Ore"] = "png",
["Azurian Outcrop"] = "png",
["Brumite Ore"] = "png",
["Echocite"] = "png",
["Eventide Ore"] = "png",
["Gloomite Ore"] = "png",
["Moonstone"] = "png",
["Mysticite"] = "png",
["Netherite Ore"] = "png",
["Nightopal"] = "png",
["Obsidian Outcrop"] = "png",
["Shadowpearl"] = "png",
["Stellarite"] = "png",
["Voidheart"] = "png",
["Witherite Ore"] = "png"
},
["skill"] = {
["Corruption"] = "png",
["Harvesting"] = "png"
},
["spell"] = {
-- Abyssal spells
["Abyssal Blast"] = "png",
["Abyssal Eruption"] = "png",
["Abyssal Surge"] = "png",
["Abyssal Wave"] = "png",
["Black Hole"] = "png",
["Brume Blast"] = "png",
["Brume Eruption"] = "png",
["Brume Surge"] = "png",
["Brume Wave"] = "png",
["Consuming Grasp"] = "png",
["Gloom Blast"] = "png",
["Gloom Eruption"] = "png",
["Gloom Surge"] = "png",
["Gloom Wave"] = "png",
["Infinite Void"] = "png",
["Madness"] = "png",
["Nether Blast"] = "png",
["Nether Eruption"] = "png",
["Nether Surge"] = "png",
["Nether Wave"] = "png",
["Null Sphere"] = "png",
["Pandemonium"] = "png",
["Tendril Slam"] = "png",
["VoidfireVolley"] = "png",
["Wither Blast"] = "png",
["Wither Eruption"] = "png",
["Wither Surge"] = "png",
["Wither Wave"] = "png"
},
["spellType"] = {
["Abyssal"] = "png"
},
["thieving"] = {
-- Abyssal NPCs
["Blighted Dryad"] = "png",
["Blighted Treant"] = "png",
["Dark Shade"] = "png",
["Dark Shadowmancer"] = "png",
["Dark Wraithlurker"] = "png",
["Silent Keeper"] = "png",
["Silent Poltergeist"] = "png",
["Silent Wanderer"] = "png",
["Turned Farmer"] = "png",
["Turned Man"] = "png",
["Turned Woman"] = "png",
["Void Envoy"] = "png",
["Void Gazer"] = "png",
["Void Shambler"] = "png",
["Withering Gargoyle"] = "png",
["Withering Golem"] = "png"
},
},
["township"] = {
["township"] = {
Line 286: Line 480:
["Nightfall"] = "png",
["Nightfall"] = "png",
["Solar Eclipse"] = "png"
["Solar Eclipse"] = "png"
},
["tree"] = {
-- Abyssal trees
["Abyssia Tree"] = "png",
["Brumia Tree"] = "png",
["Crumbletain Tree"] = "png",
["Eldria Tree"] = "png",
["Gloomia Tree"] = "png",
["Nethia Tree"] = "png",
["Plagueroot Tree"] = "png",
["Riftwood Tree"] = "png",
["Shadebark Tree"] = "png",
["Starwood Tree"] = "png",
["Twisted Tree"] = "png",
["Voidia Tree"] = "png",
["Whisperwillow Tree"] = "png",
["Withia Tree"] = "png"
}
}
}
}
Line 418: Line 629:
-- Township resources
-- Township resources
['GP'] = {'Coins', ''},
['GP'] = {'Coins', ''},
['Abyssal Pieces'] = {'Abyssal Pieces', ''},
['Food'] = {'Raw Beef', 'item'},
['Food'] = {'Raw Beef', 'item'},
['Ore'] = {'Iron', 'rock'},
['Ore'] = {'Iron', 'rock'},
Line 821: Line 1,033:
return p._SkillReq(skill, level, showText)
return p._SkillReq(skill, level, showText)
end
end
function p._AbyssalSkillReq(skill, level, showText)
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
result = result.." Abyssal Level "..level
result = '<span class="img-text">'..result..'</span>'
return result
end
function p.AbyssalSkillReq(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._AbyssalSkillReq(skill, level, showText)
end


function p._MasteryReq(itemName, level, showText)
function p._MasteryReq(itemName, level, showText)
Line 849: Line 1,080:
end
end


function p._Currency(fileName, link, altText, amount, maxAmount)
local currencyFormatDefn = {
["melvorD:GP"] = {
["img"] = 'Coins.svg',
["name"] = 'Gold Pieces',
["abbr"] = 'GP'
},
["melvorD:SlayerCoins"] = {
["img"] = 'Slayer Coins.svg',
["name"] = 'Slayer Coins',
["abbr"] = 'SC'
},
["melvorD:RaidCoins"] = {
["img"] = 'Raid Coins.svg',
["name"] = 'Raid Coins',
["abbr"] = 'RC'
},
["melvorItA:AbyssalPieces"] = {
["img"] = 'Abyssal Pieces.svg',
["name"] = 'Abyssal Pieces',
["abbr"] = 'AP'
},
["melvorItA:AbyssalSlayerCoins"] = {
["img"] = 'Abyssal Slayer Coins.svg',
["name"] = 'Abyssal Slayer Coins',
["abbr"] = 'ASC'
},
}
 
-- Aliases for the above
for k, v in pairs(currencyFormatDefn) do
if v.abbr ~= nil and currencyFormatDefn[v.abbr] == nil then
currencyFormatDefn[v.abbr] = v
end
end
 
function p._Currency(currencyID, amount, maxAmount)
local currencyDefn = currencyFormatDefn[currencyID]
if currencyDefn == nil then
error('Invalid currency ID: ' .. currencyID, 2)
end
 
local fileName, link, altText = currencyDefn.img, currencyDefn.name, currencyDefn.abbr
 
local function numColour(amount)
local function numColour(amount)
if tonumber(amount) < 0 then
if tonumber(amount) < 0 then
Line 896: Line 1,169:


function p.GP(amt, maxamt)
function p.GP(amt, maxamt)
return p._Currency('Coins.svg', 'Gold Pieces', 'GP', amt, maxamt)
return p._Currency('melvorD:GP', amt, maxamt)
end
end


function p.SC(amt, maxamt)
function p.SC(amt, maxamt)
return p._Currency('Slayer Coins.svg', 'Slayer Coins', 'SC', amt, maxamt)
return p._Currency('melvorD:SlayerCoins', amt, maxamt)
end
end


function p.RC(amt, maxamt)
function p.RC(amt, maxamt)
return p._Currency('Raid_Coins.svg', 'Raid Coins', 'RC', amt, maxamt)
return p._Currency('melvorD:RaidCoins', amt, maxamt)
end
end


Line 920: Line 1,193:
end
end
if currID == 'GP' then
return p._Currency((currID or 'nil'), minVal, maxVal)
return p.GP(minVal, maxVal)
elseif currID == 'SC' then
return p.SC(minVal, maxVal)
elseif currID == 'RC' then
return p.RC(minVal, maxVal)
else
return Shared.printError('Invalid currency: ' .. (currID == nil and 'nil' or currID))
end
end
end