No edit summary |
No edit summary |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
local p = {} |
local p = {} |
||
function p.link(name, noDlcIcon) |
function p.link(name, noDlcIcon) |
||
+ | -- look up DLC icon info for the name with DissectDlcItemName |
||
− | local icons = { |
||
+ | local tryMatch = require('Module:DissectDlcItemName').tryMatch |
||
− | -- add name parts that should be replaced with an icon here. Three parts are needed |
||
+ | local info = tryMatch(name) |
||
− | -- 1: pattern that needs to be there and that will be replace. Parenthesis need to be escaped with % |
||
+ | if info then |
||
− | -- 2: icon file name |
||
⚫ | |||
− | -- 3: link name for the icon |
||
− | {' %(The Island%)', 'The Island Icon.png', 'The Island'}, |
||
− | {' %(Scorched Earth%)', 'Scorched Earth Icon.png', 'Scorched Earth'}, |
||
− | {' %(Aberration%)', 'Aberration Icon.png', 'Aberration'}, |
||
− | {' %(Extinction%)', 'Extinction Icon.png', 'Extinction'}, |
||
− | {' %(Genesis: Part 1%)', 'Genesis Part 1 Icon.png', 'Genesis: Part 1'}, |
||
− | {' %(Genesis: Part 2%)', 'Genesis Part 2 Icon.png', 'Genesis: Part 2'}, |
||
− | {' %(Primitive Plus%)', 'Primitive Plus Icon.png', 'Primitive Plus'}, |
||
− | {' %(The Center%)', 'The Center Icon.png', 'The Center'}, |
||
− | {' %(Ragnarok%)', 'Ragnarok Icon.png', 'Ragnarok'}, |
||
− | {' %(Valguero%)', 'Valguero Icon.png', 'Valguero'}, |
||
− | {' %(Crystal Isles%)', 'Crystal Isles Icon.png', 'Crystal Isles'}, |
||
− | {' %(Mobile%)', 'Logo Mobile.svg', 'ARK: Survival Evolved Mobile|16px'}, |
||
− | {'Mod:Ebenus Astrum/', 'Ebenus Astrum Icon.png', 'Mod:Ebenus Astrum'}, |
||
− | {'Mod:Primal Fear/', 'PrimalFearIcon.png', 'Mod:Primal Fear'}, |
||
− | {'Mod:Ebenus Astrum/', 'Ebenus Astrum Icon.png', 'Mod:Ebenus Astrum'}, |
||
− | {'Mod:ARK Additions/', 'ARK Additions Icon.png', 'Mod:ARK Additions'}, |
||
− | {'Mod:Better MEKs!/', 'Mod Better MEKs! Icon.png', 'Mod:Better MEKs!'}, |
||
− | {'Mod:Steampunk/', 'Mod Steampunk Icon.png', 'Mod:Steampunk'}, |
||
− | {'Mod:Structures Plus/', 'Structures Plus Icon.png', 'Mod:Structures Plus'}, |
||
− | {'Mod:Ark Eternal/', 'Mod Ark Eternal Icon.png', 'Mod:Ark Eternal'}, |
||
− | {'Mod:Archaic Ascension/', 'Mod Archaic Ascension Icon.png', 'Mod:Archaic Ascension'}, |
||
− | {'Mod:The Chasm/', 'ChasmLogoSmall.jpg', 'Mod:The Chasm'}, |
||
− | {'Mod:Primal NPCs/', 'Mod Primal NPCs Icon.png', 'Mod:Primal NPCs'}, |
||
− | {'Mod:Caballus/', 'Mod Caballus Icon.png', 'Mod:Caballus'}, |
||
− | {'Mod:Prehistoric Beasts/', 'Mod Prehistoric Beasts Icon.png', 'Mod:Prehistoric Beasts'}, |
||
− | {'Mod:Castles, Keeps, and Forts Remastered/', 'Mod Castles Keeps Forts Architecture Remastered Icon.png', 'Mod:Castles, Keeps, and Forts Remastered'}, |
||
− | {'Mod:Crystal Isles Dino Collection/', 'Crystal Isles Dino Collection Icon.png', 'Mod:Crystal Isles Dino Collection'}, |
||
− | {'Mod:Additional Creatures: Grand Hunt/', 'Additional Creatures Grand Hunt Icon.png', 'Mod:Additional Creatures: Grand Hunt'}, |
||
− | {'Mod:Super Structures/', 'Mod Super Structures icon.png', 'Mod:Super Structures'}, |
||
− | {'Mod:ARK: The Sunken World/', 'Mod ARK The Sunken World icon.png', 'Mod:ARK: The Sunken World'}, |
||
− | } |
||
− | |||
− | for _,i in ipairs(icons) do |
||
− | if string.find(name,i[1]) ~= nil then |
||
⚫ | |||
− | end |
||
end |
end |
||
Latest revision as of 11:48, 19 September 2021
Checks if the name contains a DLC-suffix and changes it to the according DLC-icon. Then returns a link to name. Used by different templates handling DLC suffixes, such as Template:ItemLink in the example above.
Example
{{ItemLink|Aquatic Mushroom (Aberration)}}
Gives:
-- checks if the name contains a DLC-suffix and changes it to the according DLC-icon. then returns a link to name.
local p = {}
function p.link(name, noDlcIcon)
-- look up DLC icon info for the name with DissectDlcItemName
local tryMatch = require('Module:DissectDlcItemName').tryMatch
local info = tryMatch(name)
if info then
return '[['..name..'|'..info.displayName..']]'.. ((not noDlcIcon) and ' [[File:'..info.dlcIcon..'|16px|link='..info.dlcArticle..'|alt=('..info.dlcArticle..')]]' or '')
end
-- if no dlc was found, use generic approach
local title = mw.title.new(name)
if title == nil then
return 'page not found: ' .. name
end
local link = (#title.nsText > 0) and (title.fullText .. '|' .. title.text) or title.text
return '[['..link..']]'
end
return p