1,006
edits
Tag: Undo |
No edit summary |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 45: | Line 45: | ||
["Hardcore Adventure Speedrun"] = "svg", | ["Hardcore Adventure Speedrun"] = "svg", | ||
["Mastery Tokens"] = "gif", | ["Mastery Tokens"] = "gif", | ||
["Lesser Relics"] = "gif", | |||
["Prat, the Serpent of Fire"] = "svg", | ["Prat, the Serpent of Fire"] = "svg", | ||
["Unholy Prayers"] = "svg", | ["Unholy Prayers"] = "svg", | ||
Line 204: | 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 783: | Line 789: | ||
if menu then | if menu then | ||
return '{| class="articletable" style=" | 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 | return '<span class="img-text">' .. expIcon .. resultText .. '</span>' | ||
else | else | ||
return resultText | return resultText | ||
Line 804: | Line 810: | ||
result = result.." Level "..level | result = result.." Level "..level | ||
result = '<span | result = '<span class="img-text">'..result..'</span>' | ||
return result | return result | ||
end | end | ||
Line 831: | 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 | result = '<span class="img-text">'..result..'</span>' | ||
return result | return result | ||
end | end | ||
Line 843: | Line 849: | ||
end | end | ||
function p._Currency(fileName, link, altText, | function p._Currency(fileName, link, altText, amount, maxAmount) | ||
local | local function numColour(amount) | ||
if tonumber(amount) < 0 then | |||
return mw.html.create('span') | |||
:css('color', 'red') | |||
:wikitext(formatnum(amount)) | |||
:done() | |||
else | |||
return formatnum(amount) | |||
end | end | ||
end | end | ||
local html = mw.html.create('span') | |||
:addClass('img-text') | |||
local | -- Currency amounts | ||
if tonumber(amount) ~= nil then | |||
local text = mw.html.create('span') | |||
:css('margin-right', '0.2em') | |||
:node(numColour(amount)) | |||
if (tonumber(maxAmount) ~= nil and maxAmount > amount) then | |||
text:wikitext(' - ' .. numColour(maxAmount)) | |||
end | |||
html:node(text:done()) | |||
end | |||
-- Currency icon | |||
if fileName ~= nil then | if fileName ~= nil then | ||
html:wikitext('[[File:'):wikitext(fileName):wikitext('|25px') | |||
if link ~= nil then | 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 | ||
return | return tostring(html) | ||
end | end | ||
Line 874: | 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 | ||
edits