A library of functions for displaying icons on pages or within other templates. For best performance, a chain of icons (sit in a row with nothing between) should be done with a single call.
Functions
This module relies on the exists()
and trim()
contained within Module:Util. All function calls from this module are prefixed with util
e.g. util.exists()
.
_generate()
This function is internal only and the main workhorse for p.Icons()
and p.innerIcon()
. This function builds the function list. The first task is determining the size of the icons.
if util.exists(iconSetting) then
iconSetting = util.trim(iconSetting)
if util.exists(iconSize[iconSetting]) then
iconSetting = iconSize[iconSetting]
end
else
iconSetting = iconSize["medium"]
end
-- This is for calls from other Lua modules as the above will result in nil
if util.exists(iconSetting) == false then
if util.exists(iconSize) then
iconSetting = iconSize
else
iconSetting = iconSize["medium"]
end
end
In wikitext mark up the rough equivalent would be:
{{#ifeq:{{{iconSetting}}}|medium|{{#switch:{{{iconSetting}}}|a = x14px |b = 16px| c= 20px|...|#default = {{{iconSize|x14px}}}}}}}
The next step is to break the comma separated lists into a table:
if util.exists(iconLinks) then
iconLinks = mw.text.split(iconLinks, ",")
end
if util.exists(tipOverride) then
tipOverride = mw.text.split(tipOverride, ",")
end
if util.exists(iconClass)then
iconClass = "|class=" .. tostring(iconClass);
else
iconClass = ""
end
This would be the equivalent of using multiple {{#explode:}} functions and variables to store each item as its own.
Once the data has been pre-processed a loop is used to run through each item in the list to generate the icon collection:
for k, v in ipairs(iconList) do
newIcon = iconData[util.trim(v)]
if util.exists(newIcon) then
currentIcon = newIcon.icon
if util.exists(tipOverride, k) then
currentTip = tipOverride[k]
else
if util.exists(iconLinks, k) then
currentTip = iconLinks[k]
else
currentTip = newIcon.tip
end
end
else
currentIcon = "Icon question.png"
currentTip = "Unrecognized icon name"
result = result .. "[[Category:Modules with invalid parameters]]"
end
--Create wikitext icon
dataLine = '[[File:' .. currentIcon .. '|' .. iconSetting
if util.exists(iconLinks, k) then
dataLine = dataLine .. '|link=' .. iconLinks[k]
else
dataLine = dataLine .. '|link='
end
if currentTip ~= nil then
dataLine = dataLine .. '|' .. currentTip
end
dataLine = dataLine .. iconClass .. ']]'
createTip = mw.html.create('span')
createTip:addClass( 'va-icon' )
:attr('title', currentTip)
:wikitext(dataLine)
result = result .. tostring(createTip)
if k < table.getn(iconList) then
result = result .. " "
end
end
Line 2 checks the data list at Module:Icons/data for the data relating to the icon short code and returns a result or nil
(does not exist) Depending on if a result was found the code continues, if there is no match a dummy icon is supplied at lines 14/15 and a maintenance category added at line 16.
If a match is found, the next task is to check if the tooltip is being overwritten, if it isn't being overwrite, it will then check if an page alternative link has been supplied, otherwise fall back to the default tooltip.
The wikitext equivalent would be
{{{tipOverride|{{{iconLinks|default}}}}}}
Now the correct icon, tooltip and link have been obtained, lines 21-31 build the image file in the format [[File:<icon>|<size>|link=<link>|<tooltip>|class=<class>]]
.
Lines 33-37 create the <span />
which contains the icon and inserts the icon inside. When rendered this will appear as <nowik><span class="va-icon" title="<tooltip>">icon</nowiki>
.
Finally lines 39-41 check if the item being created is the last in the list to be created. If not it will add a space at the end of the string so there is space between the icons on the page once completed.
Invocation parameters
The invocation parameters are passed through from p.Icons(frame)
or p.innerIcon(iconList, iconSetting, iconLinks, tipOverride, iconClass, iconSize)
. The variables align between these three functions and the below should be taken as an explanation for all three.
Label | Parameter | Variable | Description | Required | Example |
---|---|---|---|---|---|
Icons | 1 | iconList | A string list of icon short code(s) passed through to the module. For multiple codes being passed these should be split by a comma (,). | fo76,ww | |
Icon Size | 2 | iconSetting | The image size to be passed to all icons in the list. A custom size can be set (e.g. x26px) or one of the standard sizes can be applied:
To ensure all icons are consistent in size, it is recommended to control on the height (e.g. x14px) rather than the width (e.g. 14px) |
- Defaults are built in | |
Link | 3 | iconLinks | The page(s) the icon(s) links to. For multiple pages, article names are split with a comma (,) | Fallout 76,Wild Wasteland | |
Tooltip | 4 | tipOverride | The tooltip(s) shown when hovering over the icon(s), for multiple icons, the tooltips can be split with a comma (') | - Defaults are built in | Fire, EMP |
CSS Class | 4 | iconClass | CSS classes to be applied to the icons. If this is set it will apply to all icons in the group. Classes are written without the class= component. |
va-icon va-icon-blue |
p.Icons() and p.innerIcon()
These two functions are pass through functions to _generate()
. Before passing through the list of icons supplied is split.
The differences between the functions is where they should be used and that p.innerIcon()
doesn't pass through a table of icon sizes, just a predetermined size and can only be called from other lua modules. p.Icons()
is for all other namespaces and cannot be called from another module.
Invocation parameters
Due to the close nature of these two functions and _generate()
the invocation parameters are the same as listed above.
p.platforms()
p.platforms()
uses the same data set as the other functions, but only returns results for icons that have been marked as being a platform in the data set. In addition to this, it also uses Semantic Mediawiki so the data returned can be queried in Special:Ask.
Once the function has confirmed the icon in the list is a valid platform, it will create a hidden <span />
holding the semantic tag advising of the platform assigned from the default tooltip [[Has platform::<platform>]]
. The code then largely follows that of _generate()
to create the icon, with a blank link attribute. The two spans are then joined together before checking for the next platform.
If no platforms are found the code will return <sup>[Platforms needed]</sup>[[Category:Platforms needed]]
.
Invocation parameters
The only parameter taken by this function is the iconList parameter, holding the string of short codes.
p.documentation()
p.documentation()
is self generating documentation to display the icon produced by each short code. It first takes all the datasets available and sorts them into alphabetical order and creates a table header allowing for 3 icons in a row. For each short code it will put the short code in the first, third or fifth column and the icon in the second, fourth or sixth column based on where in the sorted dataset it resides.
Due to the ever expanding icon list, this function does run the risk of becoming oversized with time. If the character size is exceeded it may need splitting into two functions.
Invocation parameters
As a self contained function, there are not parameters that can be passed through.
Available icons
Script error: The function "documentation" does not exist.
In addition, all abbreviations supported by {{Abb}}
can be used to produce an icon for the corresponding game.
local p = {}
local iconTip = {
["ability"] = "Ability",
["ac"] = "Armor class",
["acid"] = "Acid",
["action"] = "Action points",
["amber"] = "Uncorroborrated fact",
["ammo"] = "Ammunition",
["android"] = "Android OS|platform",
["ap"] = "Action points",
["apple"] = "Apple iOS|platform",
["AR"] = "All Roads",
["armorwb"] = "Armor workbench",
["atom"] = "Atom",
["attack"] = "Attack",
["big gun"] = "Big Gun, direct fire",
["bigger gun"] = "Big Gun, area of effect",
["blade"] = "Bladed melee weapon",
["bleed"] = "Bleed",
["blunt"] = "Blunt melee weapon",
["bonus effect"] = "Bonus effect",
["boss"] = "High level character",
["bronze"] = "Bronze",
["caravan"] = "Plays caravan",
["cards"] = "Cards",
["chance"] = "Armor class",
["check"] = "Armor class",
["checkbrown"] = "Armor class",
["chemst"] = "Chemistry station",
["companion"] = "Companion",
["confidence"] = "Confidence",
["cookst"] = "Cooking station",
["craft"] = "Crafting",
["crit dmg"] = "Critical damage",
["crit effect"] = "Critical effect",
["crit"] = "Critical damage",
["cross"] = "No",
["crosshair"] = "Attack",
["cut"] = "Cut content",
["D20"] = "Fallout Pen and Paper d20",
["dam/ap"] = "Damage per action point",
["damage"] = "Damage",
["dap"] = "Armor class",
["dead"] = "Dead",
["defense"] = "Defense",
["detect"] = "Detection",
["detection"] = "Detection",
["dial"] = "Dialogue",
["dialogue"] = "Dialogue",
["dislike"] = "Dislike",
["distance"] = "Distance",
["doctor"] = "Doctor",
["dps"] = "Damage per second",
["dr"] = "Damage resistance",
["dt"] = "Damage threshold",
["effect"] = "Effect",
["electrical"] = "Electrical",
["emp"] = "EMP",
["energy"] = "Energy",
["enslave"] = "Can be enslaved",
["essential"] = "Essential",
["experience"] = "Experience points",
["explmill"] = "Explosives mill",
["explosion"] = "Explosion",
["eye"] = "Detection",
["facebook"] = "Facebook",
["FB"] = "Fallout Bible",
["FBG"] = "Fallout: The Board Game",
["FBGNC"] = "Fallout: New California",
["FILM"] = "Fallout (film)",
["fire"] = "Fire",
["fist"] = "Fist",
["FNV"] = "Fallout: New Vegas",
["FNVDM"] = "Dead Money",
["FNVGRA"] = "Gun Runners' Arsenal",
["FNVHH"] = "Honest Hearts",
["FNVLR"] = "Lonesome Road (add-on)",
["FNVOWB"] = "Old World Blues (add-on)",
["fnvww"] = "Wild Wasteland",
["FO1"] = "Fallout",
["FO2"] = "Fallout 2",
["FO3"] = "Fallout 3",
["FO3BS"] = "Broken Steel",
["FO3MZ"] = "Mothership Zeta (add-on)",
["FO3OA"] = "Operation: Anchorage (add-on)",
["FO3PL"] = "Point Lookout (add-on)",
["FO3TP"] = "The Pitt (add-on)",
["FO4"] = "Fallout 4",
["FO4AUT"] = "Automatron (add-on)",
["FO4CC"] = "Creation Club",
["fo4chain01"] = "Four key chain",
["fo4chain02"] = "Five key chain",
["fo4chain03"] = "Five key chain",
["FO4CW"] = "Contraptions Workshop",
["FO4FH"] = "Far Harbor (add-on)",
["fo4gencard"] = "Generic keycard",
["fo4holo"] = "Holotape",
["fo4key01"] = "Quantum key",
["fo4key02"] = "Toy rocketship key",
["fo4key03"] = "Vault Boy key",
["fo4note"] = "Note",
["FO4NW"] = "Nuka-World (add-on)",
["fo4vaultid"] = "Vault ID card",
["FO4VR"] = "Fallout 4 VR",
["FO4VW"] = "Vault-Tec Workshop",
["FO4WW"] = "Wasteland Workshop",
["FO76"] = "Fallout 76",
["FOBOS"] = "Fallout: Brotherhood of Steel",
["FOBOS2"] = "Fallout: Brotherhood of Steel 2",
["foodpr"] = "Food processor",
["FOS"] = "Fallout Shelter",
["FOT"] = "Fallout Tactics",
["FOT2"] = "Fallout Tactics 2",
["FOX"] = "Fallout Extreme",
["frost"] = "Frost",
["FWW"] = "Fallout: Wasteland Warfare",
["gamerscore"] = "Gamerscore",
["gas"] = "Gas",
["gold"] = "Gold",
["green"] = "Reliable fact",
["grenade"] = "Grenade",
["group"] = "Group",
["gun"] = "Gun",
["hate"] = "Hate",
["healing rate"] = "Healing rate",
["healing"] = "Healing rate",
["health"] = "Health points",
["heart"] = "Health points",
["hp"] = "Health points",
["image"] = "Image",
["info"] = "Information",
["instagram"] = "Instagram",
["ios"] = "Apple iOS|platform",
["JES"] = "J.E. Sawyer's Fallout RPG",
["jury"] = "Jury Rigging",
["laser"] = "Laser",
["level"] = "Level",
["LH"] = "Lionheart",
["like"] = "Like",
["link"] = "Food processor",
["linkedin"] = "Linkedin",
["love"] = "Love",
["mac"] = "Macintosh Classic or Mac OS X|platform",
["macclassic"] = "Macintosh Classic (≤ MacOS 9)|platform",
["mag"] = "Magazine capacity",
["melee"] = "Melee",
["mentioned"] = "Mentioned",
["merchant"] = "Merchant",
["mine"] = "Mine",
["mod"] = "With mods",
["myspace"] = "Myspace",
["neutral"] = "Neutral",
["neutralface"] = "Neutral",
["no"] = "No",
["nukamix"] = "Nuka-mixer station",
["optional"] = "Optional",
["PA"] = "One Man, and a Crate of Puppets",
["parmorst"] = "Power armor station",
["pbgame"] = "Pip-Boy game",
["pc"] = "PC|platform",
["percent"] = "Chance",
["pistol"] = "Gun",
["plasma"] = "Plasma",
["platinum"] = "Platinum",
["poison"] = "Poison",
["ps3"] = "Playstation 3|platform",
["ps4"] = "Playstation 4|platform",
["PV13"] = "Project V13",
["question"] = "Question mark",
["radiation"] = "Radiation",
["range"] = "Range",
["rarity"] = "Rarity",
["ratio"] = "Ratio",
["red"] = "Unreliable or incorrect statement",
["repair"] = "Repair",
["repeat"] = "Repeat",
["required"] = "Required",
["rifle"] = "Rifle",
["robotwb"] = "Robot workbench",
["semi-required"] = "Sometimes required or at least one required",
["semi"] = "Sometimes required or at least one required",
["sequence"] = "Sequence",
["shieldbronze"] = "Armor class",
["shieldgold"] = "Damage threshold",
["shieldsilver"] = "Damage resistance",
["shotgun"] = "Shotgun",
["sic"] = "In-game spelling, punctuation and/or grammar",
["silver"] = "Silver",
["smg"] = "Submachine gun",
["sound"] = "Sound",
["spawn"] = "Spawned",
["spread"] = "Spread",
["switch"] = "Nintendo Switch|platform",
["TAR"] = "Project V13",
["temp"] = "Temporary",
["text"] = "Text",
["TORN"] = "TORN",
["tumblr"] = "Tumblr",
["twitch"] = "Twitch",
["twitter"] = "Twitter",
["unarmed"] = "Unarmed",
["VB"] = "Van Buren",
["weapwb"] = "Weapons workbench",
["weight"] = "Weight",
["wild wasteland"] = "Wild Wasteland",
["WIKI"] = "Nukapedia",
["windows"] = "Windows Phone|platform",
["workshop"] = "Workshop",
["ww"] = "Wild Wasteland",
["xbox360"] = "Xbox 360|platform",
["xboxone"] = "Xbox One|platform",
["xp"] = "Experience points",
["yes"] = "Yes",
}
local gameIcon = {
["ability"] = "Icon ability.png",
["ac"] = "Icon shield bronze.png",
["acid"] = "Icon acid.png",
["action"] = "Icon action.png",
["amber"] = "Icon amber.png",
["ammo"] = "icon ammo.png",
["android"] = "icon android.png",
["ap"] = "Icon action.png",
["apple"] = "icon appleios.png",
["ios"] = "icon appleios.png",
["AR"] = "gametitle-AR.png",
["armorwb"] = "Fo4_Armor_Work_Icon.png",
["atom"] = "Icon Fo76 Atom.png",
["attack"] = "Icon attack.png",
["big gun"] = "Icon heavy weapon.png",
["bigger gun"] = "Icon big gun.png",
["blade"] = "Icon blade.png",
["bleed"] = "Icon bleed.png",
["blunt"] = "Icon blunt.png",
["bonus effect"] = "Icon bonus effect.png",
["boss"] = "FoS Boss.png",
["bronze"] = "Bronze.png",
["caravan"] = "Icon cards.png",
["cards"] = "Icon cards.png",
["chance"] = "Icon chance.png",
["check"] = "Icon check.png",
["checkbrown"] = "Icon check temp.png",
["chemst"] = "Fo4_Chem_Work_Icon.png",
["companion"] = "Icon companion.png",
["confidence"] = "Icon confidence.png",
["cookst"] = "Fo4_Cook_Work_Icon.png",
["craft"] = "Icon crafting.png",
["crit effect"] = "Icon crit effect.png",
["crit"] = "Icon critical damage.png",
["cross"] = "Icon cross.png",
["crosshair"] = "Icon attack.png",
["cut"] = "Icon cut.png",
["D20"] = "gametitle-D20.png",
["damage"] = "Icon damage.png",
["dap"] = "Icon dap.png",
["dead"] = "Icon dead.png",
["defense"] = "Icon shield silver.png",
["detect"] = "Icon eye.png",
["detection"] = "Icon eye.png",
["dial"] = "Icon dialogue.png",
["dialogue"] = "Icon dialogue.png",
["dislike"] = "Dislike.svg",
["distance"] = "Icon range.png",
["doctor"] = "Icon doctor.png",
["dps"] = "Icon dps.png",
["dr"] = "Icon shield silver.png",
["dt"] = "Icon shield gold.png",
["effect"] = "Icon effect.png",
["electrical"] = "Icon electrical.png",
["emp"] = "Icon EMP.png",
["energy"] = "Icon electrical.png",
["enslave"] = "Icon cage.png",
["essential"] = "Icon essential.png",
["experience"] = "Icon XP.png",
["explmill"] = "Icon fo4cw builder.png",
["explosion"] = "Icon explosion.png",
["eye"] = "Icon eye.png",
["facebook"] = "FacebookIcon.png",
["FB"] = "gametitle-FB.png",
["FBG"] = "gametitle-FBG.png",
["FBGNC"] = "gametitle-FBGNC.png",
["FBGWW"] = "gametitle-FBGWW.png",
["FILM"] = "Film.png",
["fire"] = "Icon fire.png",
["fist"] = "Icon fist.png",
["FNV"] = "gametitle-FNV.png",
["FNVCS"] = "gametitle-FNV_CS.png",
["FNVDM"] = "gametitle-FNV_DM.png",
["FNVGRA"] = "gametitle-FNV_GRA.png",
["FNVHH"] = "gametitle-FNV_HH.png",
["FNVLR"] = "gametitle-FNV_LR.png",
["FNVOWB"] = "gametitle-FNV_OWB.png",
["fnvww"] = "Perk wild wasteland.png",
["FO"] = "gametitle-FO1.png",
["FO1"] = "gametitle-FO1.png",
["FO2"] = "gametitle-FO2.png",
["FO3"] = "gametitle-FO3.png",
["FO3BS"] = "gametitle-FO3_BS.png",
["FO3MZ"] = "gametitle-FO3_MZ.png",
["FO3OA"] = "gametitle-FO3_OA.png",
["FO3PL"] = "gametitle-FO3_PL.png",
["FO3TP"] = "gametitle-FO3_TP.png",
["FO4"] = "gametitle-FO4.png",
["FO4AUT"] = "gametitle-FO4_AUT.png",
["FO4CC"] = "gametitle-FO4_CC.png",
["fo4chain01"] = "icon Fo4 chain01.png",
["fo4chain02"] = "icon Fo4 chain02.png",
["fo4chain03"] = "icon Fo4 chain03.png",
["FO4CW"] = "gametitle-FO4_CW.png",
["FO4FH"] = "gametitle-FO4_FH.png",
["fo4gencard"] = "icon Fo4 gen keycard.png",
["fo4holo"] = "icon Fo4 holotape.png",
["fo4key01"] = "icon Fo4 key01.png",
["fo4key02"] = "icon Fo4 key02.png",
["fo4key03"] = "icon Fo4 key03.png",
["fo4note"] = "icon Fo4 note.png",
["FO4NW"] = "gametitle-FO4_NW.png",
["fo4vaultid"] = "icon Fo4 vaultid.png",
["FO4VR"] = "gametitle-FO4VR.png",
["FO4VW"] = "gametitle-FO4_VW.png",
["FO4WW"] = "gametitle-FO4_WW.png",
["FO76"] = "gametitle-FO76.png",
["FOBOS"] = "gametitle-FOBOS.png",
["FOBOS2"] = "gametitle-FOBOS2.png",
["foodpr"] = "Icon fo4cw builder.png",
["FOOL"] = "PV13.png",
["FOS"] = "gametitle-FOS.png",
["FOT"] = "gametitle-FOT.png",
["FOT2"] = "gametitle-FOT2.png",
["FOW"] = "gametitle-FOW.png",
["FOX"] = "gametitle-FOX.png",
["FPB"] = "gametitle-FPB.png",
["frost"] = "Icon effect.png",
["FWW"] = "gametitle-FWW.png",
["gamerscore"] = "Gamerscore.svg",
["gas"] = "Icon gas.png",
["gold"] = "Gold.png",
["green"] = "Icon green.png",
["grenade"] = "Icon grenade.png",
["group"] = "Icon group.png",
["gun"] = "Icon gun.png",
["hate"] = "Hate.svg",
["healing rate"] = "Icon healing.png",
["healing"] = "Icon healing.png",
["health"] = "Icon heart.png",
["heart"] = "Icon heart.png",
["hp"] = "Icon heart.png",
["image"] = "Icon image.png",
["info"] = "Icon info.png",
["instagram"] = "Instagram icon.jpg",
["JES"] = "gametitle-JES.png",
["jury"] = "JuryRigging.png",
["laser"] = "Icon laser.png",
["level"] = "Icon level.png",
["LH"] = "gametitle-LH.png",
["like"] = "Like.svg",
["linkedin"] = "Linkedin icon.png",
["love"] = "Love.svg",
["mac"] = "Icon mac.png",
["macclassic"] = "Icon mac.png",
["mag"] = "Assault carbine extended magazines.png",
["melee"] = "Icon melee.png",
["mentioned"] = "Icon mentioned.png",
["merchant"] = "Icon merchant.png",
["mine"] = "Icon mine.png",
["mod"] = "Icon plus.png",
["myspace"] = "Myspace icon.png",
["neutral"] = "Icon neutral.png",
["neutralface"] = "Neutral.svg",
["no"] = "Icon cross.png",
["nukamix"] = "Icon Nuka-mixer station.png",
["optional"] = "Icon optional.png",
["PA"] = "Penny Arcade.gif",
["parmorst"] = "Fo4_Power_Work_Icon.png",
["pbgame"] = "Fo4_Pip-Boy game.png",
["pc"] = "Icon pc.png",
["percent"] = "Icon chance.png",
["pistol"] = "Icon gun.png",
["plasma"] = "Icon plasma.png",
["platinum"] = "Plat.png",
["poison"] = "Icon poison.png",
["ps3"] = "Icon ps3.png",
["ps4"] = "Icon ps4.png",
["PV13"] = "PV13.png",
["question"] = "Icon question.png",
["radiation"] = "Icon radiation.png",
["range"] = "Icon range.png",
["rarity"] = "Icon rarity.png",
["ratio"] = "Icon ratio.png",
["red"] = "Icon red.png",
["repair"] = "Icon repair.png",
["repeat"] = "Icon repeat.png",
["required"] = "Icon required.png",
["rifle"] = "Icon rifle.png",
["robotwb"] = "Icon robot workbench.png",
["semi-required"] = "Icon semi-required.png",
["semi"] = "Icon semi-required.png",
["sequence"] = "Icon sequence.png",
["shieldbronze"] = "Icon shield bronze.png",
["shieldgold"] = "Icon shield gold.png",
["shieldsilver"] = "Icon shield silver.png",
["shotgun"] = "Icon shotgun.png",
["sic"] = "Icon sic.png",
["silver"] = "Silver.png",
["smg"] = "Icon smg.png",
["sound"] = "Icon sound.png",
["spawn"] = "Icon spawn.png",
["spread"] = "Icon spread.png",
["switch"] = "Nintendo Switch icon.png",
["TAR"] = "gametitle-TAR.jpg",
["temp"] = "Icon check temp.png",
["text"] = "Icon text.png",
["TORN"] = "gametitle-TORN.png",
["tumblr"] = "Tumblr Icon.png",
["twitch"] = "Twitch icon.png",
["twitter"] = "Twitter icon.jpg",
["unarmed"] = "Icon unarmed.png",
["VB"] = "gametitle-VB.png",
["weapwb"] = "Fo4_Weapon_Work_Icon.png",
["weight"] = "Icon weight.png",
["WIKI"] = "gametitle-Wiki.png",
["wild wasteland"] = "Perk wild wasteland.png",
["windows"] = "Icon windows.png",
["workshop"] = "Icon workshop.png",
["ww"] = "Perk wild wasteland.png",
["xbox360"] = "Icon xbox360.png",
["xboxone"] = "Icon xboxone.png",
["xp"] = "Icon XP.png",
["yes"] = "Icon check.png",
}
local iconSize = {
["small"] = "x10px",
["medium"] = "x14px",
["normal"] = "x14px",
["big"] = "x20px",
}
function p.Icons(frame)
local iconList = mw.text.split(frame.args[1], ",")
local parserError = ""
local iconSetting
if frame.args[2] ~= nil and string.len(frame.args[2]) > 0 then
iconSetting = tostring(frame.args[2])
if iconSize[iconSetting] ~= nil then
iconSetting = iconSize[iconSetting]
end
else
iconSetting = iconSize["medium"]
end
local iconLinks
if frame.args[3] ~= nil then
iconLinks = mw.text.split(frame.args[3], ",")
end
local tipOverride
if frame.args[4] ~= nil then
tipOverride = mw.text.split(frame.args[4], ",")
end
local n = 1
local result = ""
while n <= table.getn(iconList) do
newIcon = iconList[n]
if gameIcon[newIcon] ~= nil then
currentIcon = gameIcon[newIcon]
if tipOverride ~= nil and tipOverride[n] ~= nil then
currentTip = tipOverride[n]
else
if iconLinks ~= nil and iconLinks[n] ~= nil then
currentTip = iconLinks[n]
else
splitTip = mw.text.split(iconTip[newIcon], "|")
currentTip = splitTip[1]
end
end
else
currentIcon = "Icon question.png"
currentTip = "Unrecognized icon name"
result = result .. "[[Category:Modules with invalid parameters]]"
end
result = result .. '<span class="va-icon" title="' .. currentTip .. '">'
result = result .. '[' .. '[File:' .. currentIcon .. '|' .. iconSetting
if iconLinks ~= nil and iconLinks[n] ~= nil and iconLinks[n] ~= "" then
result = result .. '|link=' .. iconLinks[n]
else
result = result .. '|link='
end
if currentTip ~= nil then
result = result .. '|' .. currentTip
end
result = result .. ']]</span>'
if n < table.getn(iconList) then
result = result .. " "
end
n = n + 1
end
return result .. parserError
end
function p.platforms(frame)
local icons = mw.text.split(frame.args[1], ",")
local iconCount = 1
local platformCheck = ""
local result = ""
while iconCount <= table.getn(icons) do
currentIcon = iconTip[icons[iconCount]]
platformCheck = mw.text.split(currentIcon, "|")
if platformCheck[2] ~= nil then
result = result .. '<span style="display: none;">' .. "[[Has platform::"
result = result .. platformCheck[1] .. ']]</span>'
result = result .. '<span class="va-icon" title="' .. platformCheck[1] .. '">'
result = result .. "[".."[File:" .. gameIcon[icons[iconCount]] .. "|x14px|link=]]"
result = result .. '</span>'
if iconCount < table.getn(icons) then
result = result .. " "
end
end
iconCount = iconCount + 1
end
if result == "" then
result = '<sup>[Platforms needed]</sup>[[Category:Platforms needed]]'
end
return result
end
function p.Test(frame)
local iconList = mw.text.split(frame.args[1], ",")
local parserError = ""
local iconSetting
if frame.args[2] ~= nil and string.len(frame.args[2]) > 0 then
iconSetting = tostring(frame.args[2])
if iconSize[iconSetting] ~= nil then
iconSetting = iconSize[iconSetting]
end
else
iconSetting = iconSize["medium"]
end
local iconLinks
if frame.args[3] ~= nil then
iconLinks = mw.text.split(frame.args[3], ",")
end
local tipOverride
if frame.args[4] ~= nil then
tipOverride = mw.text.split(frame.args[4], ",")
end
local n = 1
local result = ""
while n <= table.getn(iconList) do
newIcon = iconList[n]
if gameIcon[newIcon] ~= nil then
currentIcon = gameIcon[newIcon]
if tipOverride ~= nil and tipOverride[n] ~= nil then
currentTip = 'overide text'
else
if iconLinks ~= nil and iconLinks[n] ~= nil then
currentTip = iconLinks[n]
else
splitTip = mw.text.split(iconTip[newIcon], "|")
currentTip = splitTip[1]
end
end
else
currentIcon = "Icon question.png"
currentTip = "Unrecognized icon name"
result = result .. "[[Category:Modules with invalid parameters]]"
end
result = result .. 'Current tip: <span title="' .. currentTip .. '">' .. currentTip .. "</span>: " .. string.len(currentTip) .. '\n'
result = result .. ']]</span>'
if n < table.getn(iconList) then
result = result .. " "
end
n = n + 1
end
return result .. parserError
end
return p