Editing Module:IconUtils
From Eco - English Wiki
Your changes will be displayed to readers once an authorized user accepts them. (help)
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
function p.main(param) | function p.main(param) | ||
local Utils = require('Module:Utils') | local Utils = require('Module:Utils') | ||
local itemData = mw.loadData("Module:ItemData") | |||
local Icon = '' | local Icon = '' | ||
local IconStyle = '' | local IconStyle = '' | ||
Line 11: | Line 11: | ||
local args = Utils.normaliseArgs(param) | local args = Utils.normaliseArgs(param) | ||
if args.name == nil or args.name == '' then return '\'name\' must be specified.' end | if args.name == nil or args.name == '' then return '\'name\' must be specified.' end | ||
local itemTable = itemData.items[args.name] | local itemTable = itemData.items[args.name] | ||
if itemTable == nil then return args.name .. ' could not be found ' end | if itemTable == nil then return args.name .. ' could not be found ' end | ||
if args.size == nil or args.size == '' then IconSize = 28 else IconSize = args.size end | |||
local ItemEN = itemTable.untranslated | local ItemEN = itemTable.untranslated | ||
local IconName = string.gsub(ItemEN, ' ', '') .. 'Item' | local IconName = string.gsub(ItemEN, ' ', '') .. 'Item' | ||
Icon = Utils.checkImage(IconName) | Icon = Utils.checkImage(IconName) | ||
if args.style == nil or args.style == '' then IconStyle = '1' else IconStyle = args.style end | if args.style == nil or args.style == '' then IconStyle = '1' else IconStyle = args.style end | ||
if args.link == nil or args.link == '' then IconLink = '' else IconLink = '[[' .. args.link .. ']]' end | if args.link == nil or args.link == '' then IconLink = '' else IconLink = '[[' .. args.link .. ']]' end | ||
Line 29: | Line 27: | ||
if IconStyle == '2' then return '[[file:'.. Icon ..'|'.. IconSize ..'px|link='.. IconLink ..']]' .. IconTextLine end | if IconStyle == '2' then return '[[file:'.. Icon ..'|'.. IconSize ..'px|link='.. IconLink ..']]' .. IconTextLine end | ||
if IconStyle == '3' then return '[[file:'.. Icon ..'|'.. IconSize ..'px|link='.. IconLink ..']]' .. IconTextBr end | if IconStyle == '3' then return '[[file:'.. Icon ..'|'.. IconSize ..'px|link='.. IconLink ..']]' .. IconTextBr end | ||
if IconStyle == '4' then return ' | if IconStyle == '4' then return '[[file:'.. Icon ..'|'.. IconSize ..'px|link='.. IconLink ..']]' .. IconTextBr end | ||
end | end | ||
return p | return p |