Module:SpriteFile: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Tag: Reverted
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"
local link = ( args.link or '' )
end
if mw.ustring.lower( link ) == 'none' then
end
link = ''
elseif link ~= '' then
local linkPrefix = ( not link:find( '//' ) and args.linkprefix ) or ''
link = linkPrefix .. link
end
-- -- Edited to turn regular links into vanilla: prefixes 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 36: Line 35:
-- 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 == '' then  -- <- these are the added bits here
-- linkprefix = 'vanilla:' 
-- elseif linkprefix == 'parallel:' then
-- linkprefix = ''
-- end
-- link = linkPrefix .. link
-- link = linkPrefix .. link
-- end
-- end
-- Edited to turn regular links into vanilla: prefixes and to turn parallel: prefixes into regular links
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 ''
if linkprefix == '' then  -- <- these are the added bits here
linkprefix = 'vanilla:' 
elseif linkprefix == 'parallel:' then
linkprefix = ''
end
link = linkPrefix .. link
end
local scale = args.scale or default.scale
local scale = args.scale or default.scale
Line 70: Line 60:
name = 'Invicon'
name = 'Invicon'
end
end
-- local file = name .. ' ' .. id .. '.png'
local file = name .. ' ' .. id .. '.png'
local file = idPrefix .. name .. ' ' .. id .. '.png'
local altText = file .. ': Sprite image for ' .. id .. ' in Minecraft'
local altText = file .. ': Sprite image for ' .. id .. ' in Minecraft'
if link ~= '' then
if link ~= '' then
Line 107: Line 96:
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
else
if string.find(link, "parallel:") then  -- <---- this sub-if/else statement is new
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
-- have to do this weird inner tostring here bc something about converting the spriteText table causes the text indentation to be correct
spriteText = '[[' .. mw.ustring.gsub( link, "parallel:", "" ) .. '|' .. mw.ustring.gsub( tostring(spriteText), "parallel:", "" ) .. ']]'
else
spriteText = '[[' .. 'Vanilla:' .. link .. '|' .. tostring( spriteText ) .. ']]'
end
end
end
end
end

Navigation menu