Module:Sandbox/User:Alsang/PotionList: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(implement "unkown" table format)
(remove vestigial KP per hour calcs, add in thousands separator commas)
 
Line 2: Line 2:
local param = require( 'Module:Paramtest' )
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local currency = require('Module:Currency')
local lang = mw.getContentLanguage()
require("Module:Mw.html extension")




Line 105: Line 107:
item.hasDuration = param.has_content(item.brewDuration) and param.has_content(item.prepDuration)
item.hasDuration = param.has_content(item.brewDuration) and param.has_content(item.prepDuration)
-- XP/KP strings, if the requisite data isnt there then display "unknown"
if item.hasXP then
--item.xp = lang:formatNum(item.xp) -- format to include commas
item.XP = item.XP -- format to include commas
else
item.XP = 'Unknown'
end
if item.hasKP then
item.KP = item.KP .. '%' -- want 1 decimal place
else
item.KP = 'Unknown'
end
if item.hasXP and item.hasDuration then
item.XPPerHour = item.XPPerHour -- format to include commas
else
item.XPPerHour = 'Unknown'
end
if item.hasKP and item.hasDuration then
item.KPPerHour = item.KPPerHour -- want 2 decimal places
else
item.KPPerHour = 'Unknown'
end
end
end


Line 178: Line 153:
:wikitext('Coins/XP')
:wikitext('Coins/XP')
:done()
:done()
--:tag('th')
-- :wikitext('KP')
--:done()
--:tag('th')
-- :wikitext('KP/hr')
--:done()
:done()
:done()
Line 229: Line 198:
:IF(item.hasSell)
:IF(item.hasSell)
-- I cannot for the life of me figure out why,
-- but if I put item.sell directly into this function it claims it has value nil
-- it works for other functions to display it directly
-- so here is the workaround I guess
--:wikitext(currency_cell(item.buy+200*item.profit))
:wikitext(currency_cell(item.sell))
:wikitext(currency_cell(item.sell))
:ELSE()
:ELSE()
Line 268: Line 232:
:tag('td')
:tag('td')
:IF(item.hasXP)
:IF(item.hasXP)
:wikitext(item.XP)
:wikitext(lang:formatNum(tonumber(item.XP)))
:ELSE()
:ELSE()
:addClass('table-bg-grey')
:addClass('table-bg-grey')
Line 278: Line 242:
:tag('td')
:tag('td')
:IF(item.hasXP and item.hasDuration)
:IF(item.hasXP and item.hasDuration)
:wikitext(item.XPPerHour)
:wikitext(lang:formatNum(tonumber(item.XPPerHour)))
:ELSE()
:ELSE()
:addClass('table-bg-grey')
:addClass('table-bg-grey')