Module:Icons: Difference between revisions

no edit summary
m (Added Lesser Relics as a gif)
No edit summary
 
(9 intermediate revisions by 3 users not shown)
Line 205: Line 205:
["Trickery Temple"] = "png",
["Trickery Temple"] = "png",
["Underwater City"] = "png",
["Underwater City"] = "png",
["Underwater Ruins"] = "png"
["Underwater Ruins"] = "png",
["Eye-conic Cave"] = "png",
["Mucky Cave"] = "png",
["Lost Temple"] = "png",
["Ritual Site"] = "png",
["Shipwreck Cove"] = "png",
}
}
}
}
Line 784: Line 789:


if menu then
if menu then
return '{| class="articletable" style="display:inline-block;vertical-align:middle;"\r\n|-\r\n|' .. expIcon .. resultText .. '\r\n|}'
return '{| class="articletable img-text" style="vertical-align:middle;"\r\n|-\r\n|' .. expIcon .. resultText .. '\r\n|}'
elseif not noicon and not nospan then
elseif not noicon and not nospan then
return '<span style="display:inline-block">' .. expIcon .. resultText .. '</span>'
return '<span class="img-text">' .. expIcon .. resultText .. '</span>'
else
else
return resultText
return resultText
Line 805: Line 810:
result = result.." Level "..level
result = result.." Level "..level


result = '<span style="display:inline-block">'..result..'</span>'
result = '<span class="img-text">'..result..'</span>'
return result
return result
end
end
Line 832: Line 837:
result = result..p.Icon({linkname, img=iconname, type='item', notext=true, nospan=true, alt=altTextItem})..p.Icon({'Mastery', notext=true, nospan=true, alt=altTextMastery})
result = result..p.Icon({linkname, img=iconname, type='item', notext=true, nospan=true, alt=altTextItem})..p.Icon({'Mastery', notext=true, nospan=true, alt=altTextMastery})
if showText then result = result..'[['..linkname..']] [[Mastery]]' end
if showText then result = result..'[['..linkname..']] [[Mastery]]' end
result = '<span style="display:inline-block">'..result..'</span>'
result = '<span class="img-text">'..result..'</span>'
return result
return result
end
end
Line 845: Line 850:


function p._Currency(fileName, link, altText, amount, maxAmount)
function p._Currency(fileName, link, altText, amount, maxAmount)
local ret = {}
local function numColour(amount)
table.insert(ret, '<span style="display:inline-block">')
if tonumber(amount) < 0 then
-- Currency icon
return mw.html.create('span')
if fileName ~= nil then
:css('color', 'red')
table.insert(ret, '[[File:' .. fileName .. '|25px')
:wikitext(formatnum(amount))
if link ~= nil then
:done()
table.insert(ret, '|link=' .. link)
else
return formatnum(amount)
end
end
table.insert(ret, '|alt=' .. ((altText == nil and '') or altText) .. ']]')
end
end
local html = mw.html.create('span')
:addClass('img-text')
-- Currency amounts
-- Currency amounts
if tonumber(amount) ~= nil then
if tonumber(amount) ~= nil then
local function numColour(amount)
local text = mw.html.create('span')
if tonumber(amount) < 0 then
:css('margin-right', '0.2em')
return '<span style="color:red;">' .. formatnum(amount) .. '</span>'
:node(numColour(amount))
else
if (tonumber(maxAmount) ~= nil and maxAmount > amount) then
return formatnum(amount)
text:wikitext(' - ' .. numColour(maxAmount))
end
end
end
table.insert(ret, '&nbsp;' .. numColour(amount))
html:node(text:done())
if (tonumber(maxAmount) ~= nil and maxAmount > amount) then
end
table.insert(ret, ' - ' .. numColour(maxAmount))
-- Currency icon
if fileName ~= nil then
html:wikitext('[[File:'):wikitext(fileName):wikitext('|25px')
if link ~= nil then
html:wikitext('|link='):wikitext(link)
end
end
html:wikitext('|alt=')
:wikitext(((altText == nil and '') or altText))
:wikitext(']]')
end
html:done()
if ((amount ~= nil and tonumber(amount) == nil)
or (maxAmount ~= nil and tonumber(maxAmount) == nil)) then
html:wikitext('[[Category:Pages with non-numeric currency arguments]]')
end
end
table.insert(ret, '</span>')
return table.concat(ret)
return tostring(html)
end
end


Line 884: Line 905:
function p.RC(amt, maxamt)
function p.RC(amt, maxamt)
return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', 'RC', amt, maxamt)
return p._Currency('Raid_Coins.svg', 'Currency#Raid Coins', 'RC', amt, maxamt)
end
-- p.Currency() is called by various currency templates:
-- [[Template:GP]], [[Template:SC]], [[Template:RC]]
function p.Currency(frame)
local args = frame.args ~= nil and frame.args or frame
local currID, minVal, maxVal, _
currID = args[1]
if args[2] ~= nil and args[2] ~= '' then
minVal, _ = string.gsub(args[2], ',', '')
end
if args[3] ~= nil and args[3] ~= '' then
maxVal, _ = string.gsub(args[3], ',', '')
end
if currID == 'GP' then
return p.GP(minVal, maxVal)
elseif currID == 'SC' then
return p.SC(minVal, maxVal)
elseif currID == 'RC' then
return p.RC(minVal, maxVal)
else
return Shared.printError('Invalid currency: ' .. (currID == nil and 'nil' or currID))
end
end
end


918

edits