Module:Icon: Difference between revisions

Valaerys (talk | contribs)
Created page with "-- Module copied from the Genshin Impact wiki -- Revision as of 4-29-2023 --- A library that other modules can use to create icon images with automatic prefix/suffix settings for items, characters, and weapons. -- (Other icon types must have their types/suffixes specified manually.) -- -- '''Note:''' this module is (currently) NOT related to Template:Icon. -- -- @script Icon local TemplateData = require('Module:TemplateData') local p = {} -- icon arg defaults..."
 
Valaerys (talk | contribs)
No edit summary
Line 33: Line 33:
label='File Prefix',
label='File Prefix',
description='The file prefix to prepend to {labelPrefix}Name.',
description='The file prefix to prepend to {labelPrefix}Name.',
example={'Item', 'Light Cone', 'Character', 'Icon'}
example={'Item', 'Nexus Strand', 'Relic', 'Icon'}
},
},
{name='suffix', displayDefault='determined based on {labelPrefix}Name/{labelPrefix}Type',
{name='suffix', displayDefault='determined based on {labelPrefix}Name/{labelPrefix}Type',
Line 158: Line 158:
local ALL_DATA = {-- list of {type, data} in the order that untyped items should get checked
local ALL_DATA = {-- list of {type, data} in the order that untyped items should get checked
{'Character', mw.loadData('Module:Card/characters')},
{'Character', mw.loadData('Module:Card/characters')},
{'Anima', mw.loadData('Module:Card/animas')},
{'Relic', mw.loadData('Module:Card/relics')},
{'Nexus Strand', mw.loadData('Module:Card/nexusstrands')},
{'Item', mw.loadData('Module:Card/items')} -- Always leave this one as the last in this list
{'Item', mw.loadData('Module:Card/items')} -- Always leave this one as the last in this list
}
}
Line 302: Line 305:
     The main entry point for other modules.
     The main entry point for other modules.
     Creates and returns an Image object with the given arguments.
     Creates and returns an Image object with the given arguments.
     Infers `args.type` if `args.name` matches a known item/character/Light Cone.
     Infers `args.type` if `args.name` matches a known item/character/relic.
     @param {table} args Table containing the arguments:
     @param {table} args Table containing the arguments:
     @param[opt] {string} args.name The name of the image.
     @param[opt] {string} args.name The name of the image.
Line 352: Line 355:
      
      
     -- set defaults and load data based on type
     -- set defaults and load data based on type
     if image_type == 'Character' or image_type == 'Currency Wars Character' then
     if image_type == 'Character' then
image.prefix = 'Character'
image.defaults.suffix = 'Character Icon'
image.defaults.suffix = 'Icon'
     elseif image_type == 'Anima' then
     elseif image_type == 'Element' then
image.defaults.suffix = 'Anima Icon'
image.prefix = 'Type'
elseif image_type == 'Item' then
elseif image_type == 'Consumable' then
image.prefix = 'Item'
image.prefix = 'Item'
elseif image_type == 'Relic' then
elseif image_type == 'Relic' then
image.prefix = 'Item'
image.prefix = 'Relic'
elseif image_type == 'Profile Picture' then
elseif image_type == 'Nexus Strand' then
image.prefix = 'Profile Picture'
image.prefix = 'Nexus Strand'
image.link = image.name
image.name = image.name:gsub(' %(Profile Picture%)', '')
elseif image_type == 'Enemy' or image_type == 'Aether Enemy' then
image.prefix = 'Icon Enemy'
image.link = (data and data.link) or image.name
image.defaults.suffix = ''
end
end
return image, image_type, data
return image, image_type, data