Module:SpriteFile: Difference between revisions

Reinstate support for custom Parallel items
m (1 revision imported)
(Reinstate support for custom Parallel items)
 
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%+]', '-' )
end
if string.find(id, "parallel:") then
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 26: Line 45:
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
Line 47: Line 77:
end
end
local extension = name == 'Dungeons2AchievementSprite' and '.jpg' or name == '' and '' or '.png'
local extension = name == 'Dungeons2AchievementSprite' and '.jpg' or name == '' and '' or '.png'
local file = name .. ' ' .. id .. extension
-- local file = name .. ' ' .. id .. extension
local file = idPrefix .. name .. ' ' .. id .. extension
local altText = ''
local altText = ''
if link == '' then
if link == '' then
Line 82: Line 113:
if link:find( '//' ) then
if link:find( '//' ) then
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
-- else
-- spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
-- end
else
else
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
-- if string.find(link, " (Vanilla)") then -- <-- this inner if/else statement is added
-- 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