Module:SpriteFile: Difference between revisions

Set sprite file extension to jpg if used on Dungeons2AchievementSprite
No edit summary
(Set sprite file extension to jpg if used on Dungeons2AchievementSprite)
Line 15: Line 15:
align = 'text-top'
align = 'text-top'
}
}
-- local id = mw.text.trim( tostring( args[1] or '' ) )
-- if not args.keepcase then
-- id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' )
-- end
local id = mw.text.trim( tostring( args[1] or '' ) )
local id = mw.text.trim( tostring( args[1] or '' ) )
local idPrefix = ""
if not args.keepcase then
if not args.keepcase then
id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' )
id = mw.ustring.lower( id ):gsub( '[%s%+]', '-' )
if string.find(id, "parallel:") then
end
id = mw.ustring.lower( id ):gsub( 'parallel:', '' )
idPrefix = "Parallel"
end
end
-- local link = ( args.link or '' )
-- if mw.ustring.lower( link ) == 'none' then
-- link = ''
-- elseif link ~= '' then
-- local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
-- link = linkPrefix .. link
-- end
-- Edited to turn regular links into links with ' (Vanilla)' at the end and to turn parallel: prefixes into regular links
local link = ( args.link or '' )
local link = ( args.link or '' )
if mw.ustring.lower( link ) == 'none' then
if mw.ustring.lower( link ) == 'none' then
Line 45: Line 26:
elseif link ~= '' then
elseif link ~= '' then
local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
if linkPrefix == "parallel:" then  -- <- these are the added bits here
linkprefix = '' 
end
if string.find(link, "[Pp]arallel:") then
link = mw.ustring.gsub( link, "[Pp]arallel:", "" )
else
if mw.title.new(link).exists == false then
linkPrefix = 'mcwiki:'
end
-- link = link .. ' (Vanilla)'
end
link = linkPrefix .. link
link = linkPrefix .. link
end
end
local scale = args.scale or default.scale
local scale = args.scale or default.scale
Line 72: Line 42:
end
end
local name = args.name
local name = args.name or ''
if name == 'InvSprite' then
if name == 'InvSprite' then
name = 'Invicon'
name = 'Invicon'
end
end
-- local file = name .. ' ' .. id .. '.png'
local extension = name == 'Dungeons2AchievementSprite' and '.jpg' or name == '' and '' or '.png'
local file = idPrefix .. name .. ' ' .. id .. '.png'
local file = name .. ' ' .. id .. extension
local altText = file .. ': Sprite image for ' .. id .. ' in Minecraft'
local altText = ''
if link ~= '' then
if link == '' then
altText = altText .. ' linking to ' .. link
altText = file .. ': Sprite image for ' .. id .. ' in Minecraft'
end
end
if id == '' then
if id == '' then
Line 113: Line 83:
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
else
-- if string.find(link, " (Vanilla)") then -- <-- this inner if/else statement is added
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
-- spriteText = '[[' .. link .. '|' .. tostring( spriteText ):gsub(" (Vanilla)", "") .. ']]'
if string.find(tostring(spriteText), "[Pp]arallel:") then
text = tostring(spriteText):gsub(":%l", string.upper)
text = text:gsub("[Pp]arallel:", "")
spriteText = '[[' .. link .. '|' .. text .. ']]'
else
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
end
end
end