Module:SpriteFile: Difference between revisions
m 1 revision imported |
No edit summary |
||
| Line 17: | Line 17: | ||
local id = mw.text.trim( tostring( args[1] or '' ) ) | local id = mw.text.trim( tostring( args[1] or '' ) ) | ||
if not args.keepcase then | if not args.keepcase then | ||
id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' ) | id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' ) | ||
end | end | ||
local mod = id:match( '([^:%]]+):' ) or "Minecraft" | |||
local nameStart = ( id:find( ':' ) or id:find( '%]' ) or 0 ) + 1 | |||
if nameStart - 1 == #id then | |||
nameStart = 1 | |||
end | |||
local nameId = id:sub( nameStart, ( id:find( '[,%[]', nameStart ) or 0 ) - 1 ) | |||
local link = ( args.link or '' ) | local link = ( args.link or '' ) | ||
| Line 46: | Line 55: | ||
name = 'Invicon' | name = 'Invicon' | ||
end | end | ||
local file = name .. ' ' .. id .. '.png' | local file = '' | ||
if mod == 'Minecraft' or mod == 'minecraft' then | |||
file = name .. ' ' .. id .. '.png' | |||
else | |||
file = name .. mod .. ' ' .. id .. '.png' | |||
end | |||
local altText = '' | local altText = '' | ||
if link == '' then | if link == '' then | ||
altText = file .. ': Sprite image for ' .. id .. ' in | altText = file .. ': Sprite image for ' .. id .. ' in ' .. mod | ||
end | end | ||
if id == '' then | if id == '' then | ||
| Line 76: | Line 92: | ||
if args.title then | if args.title then | ||
spriteText:attr( 'title', args.title ) | spriteText:attr( 'title', args.title ) | ||
else | |||
spriteText:attr( 'title', nameId ) | |||
end | end | ||
if link ~= '' then | if link ~= '' then | ||