Module:SpriteFile: Difference between revisions

no edit summary
No edit summary
Tag: Manual revert
No edit summary
 
(33 intermediate revisions by the same user not shown)
Line 39: Line 39:
-- end
-- end
-- Edited to turn regular links into vanilla: prefixes and to turn parallel: prefixes into regular links
-- 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 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
if linkPrefix == "parallel:" then  -- <- these are the added bits here
linkprefix = ''   
linkprefix = ''   
end
if string.find(link, "[Pp]arallel:") then
link = mw.ustring.gsub( link, "[Pp]arallel:", "" )
else
link = link .. ' (Vanilla)'
end
end
link = linkPrefix .. link
link = linkPrefix .. link
Line 105: Line 110:
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
else
if string.find(link, "parallel:") then   -- <---- this sub-if/else statement is new
if string.find(link, " (Vanilla)") then -- <-- this inner if/else statement is added
-- have to do this weird inner tostring here bc something about converting the spriteText table causes the text indentation to be correct
spriteText = '[[' .. link .. '|' .. tostring( spriteText ):gsub(" (Vanilla)", "") .. ']]'
spriteText = '[[' .. mw.ustring.gsub( link, "[Pp]arallel:", "" ):gsub("^%l", string.upper) .. '|' .. mw.ustring.gsub( tostring(spriteText), "[Pp]arallel:", "" ):gsub("^%l", string.upper) .. ']]'  
elseif string.find(tostring(spriteText), "[Pp]arallel:") then
text = tostring(spriteText):gsub(":%l", string.upper)
text = text:gsub("[Pp]arallel:", "")
spriteText = '[[' .. link .. '|' .. text .. ']]'
else
else
spriteText = '[[' .. link .. ' (Vanilla)' .. '|' .. tostring( spriteText ) .. ']]'
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
end
end
end
end