Module:SpriteFile: Difference between revisions

Jump to navigation Jump to search
Undo revision 7685 by Diamondback88 (talk)
No edit summary
Tag: Reverted
(Undo revision 7685 by Diamondback88 (talk))
Tag: Undo
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 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 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 == '' 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 60: Line 70:
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 96: Line 107:
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
spriteText = '[' .. link .. ' ' .. tostring( spriteText ) .. ']'
else
else
spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]'
if string.find(link, "parallel:") then  -- <---- this sub-if/else statement is new
-- 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