8,461
edits
No edit summary Tag: Reverted |
(Reinstate support for custom Parallel items) |
||
| (43 intermediate revisions by 2 users not shown) | |||
| Line 39: | Line 39: | ||
-- end | -- end | ||
-- Edited to turn regular links into | -- 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 | 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 | |||
if mw.title.new(link).exists == false then | |||
linkPrefix = 'mcwiki:' | |||
end | |||
-- link = link .. ' (Vanilla)' | |||
end | end | ||
link = linkPrefix .. link | link = linkPrefix .. link | ||
end | end | ||
local scale = args.scale or default.scale | local scale = args.scale or default.scale | ||
| Line 64: | Line 72: | ||
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 .. | local extension = name == 'Dungeons2AchievementSprite' and '.jpg' or name == '' and '' or '.png' | ||
local file = idPrefix .. name .. ' ' .. id .. | -- local file = name .. ' ' .. id .. extension | ||
local altText = | local file = idPrefix .. name .. ' ' .. id .. extension | ||
if link | local altText = '' | ||
altText = | if link == '' then | ||
altText = file .. ': Sprite image for ' .. id .. ' in Minecraft' | |||
end | end | ||
if id == '' then | if id == '' then | ||
| Line 79: | Line 88: | ||
end | end | ||
local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' ) | local sprite = mw.html.create( 'span' ):addClass( 'sprite-file' ) | ||
local img = '[[File:' .. file .. '|' .. size .. '|link=' .. link .. '|alt=' .. altText .. '|class=pixel-image|' .. ( args.title or '' ) .. ']]' | local img = '[[File:' .. file .. '|' .. size .. '|link=' .. link .. '|alt=' .. altText .. '|class=pixel-image|' .. ( args.title or '' ) .. ']]' | ||
sprite:node( img ) | sprite:node( img ) | ||
| Line 109: | 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 | ||
if string.find(link, " | -- 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 | else | ||
spriteText = '[[' .. link | spriteText = '[[' .. link .. '|' .. tostring( spriteText ) .. ']]' | ||
end | end | ||
end | end | ||
end | end | ||