Module:Icon: Difference between revisions
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..." |
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', ' | 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/ | 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 == ' | if image_type == 'Character' then | ||
image.defaults.suffix = 'Character Icon' | |||
image.defaults.suffix = 'Icon' | elseif image_type == 'Anima' then | ||
elseif image_type == ' | image.defaults.suffix = 'Anima Icon' | ||
image. | elseif image_type == 'Item' then | ||
elseif image_type == ' | |||
image.prefix = 'Item' | image.prefix = 'Item' | ||
elseif image_type == 'Relic' then | elseif image_type == 'Relic' then | ||
image.prefix = ' | image.prefix = 'Relic' | ||
elseif image_type == ' | elseif image_type == 'Nexus Strand' then | ||
image.prefix = ' | image.prefix = 'Nexus Strand' | ||
end | end | ||
return image, image_type, data | return image, image_type, data | ||