Module:Sandbox/User:Alsang/PotionList: Difference between revisions
Module:Sandbox/User:Alsang/PotionList (edit)
Revision as of 19:12, 27 November 2024
, Yesterday at 19:12rename the SMW properties "Recipe XP", "Recipe KP", and "Recipe duration" to "Activity XP", "Activity KP", and "Activity duration" so they can generate the same fields as Template:Profession info
(reorder columns) |
(rename the SMW properties "Recipe XP", "Recipe KP", and "Recipe duration" to "Activity XP", "Activity KP", and "Activity duration" so they can generate the same fields as Template:Profession info) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1:
require('Module:Mw.html extension')
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local p = {}
-- non dynamic module, no inputs
Line 10 ⟶ 13:
'[[Category:Potions]]',
'[[Uses facility::Standard Potion Station||Potent Potion Station]]',
'?Profession Level A = lvl',
'? #- = name',
'?Uses item.Uses item #- = reagents',
'?Value = sell',
'?
'?Uses item.
'?
'?Uses item.
'?
'?Uses item.
'sort = Profession Level A'
}
local results = mw.smw.ask(query)
results = p.
return p.displayTable(results)
end
-- makes the html for the cells containing currency directly, no tags needed
-- flag is for if the number should not be known, replaces with zero
local function currency_cell(amount,flag)
local a = {}
if flag then
a = currency._cell(amount, { html = 'yes' })
else
a = currency._cell(0, { html = 'yes' }) -- replace this with blank, if I can figure out how to
end
return a
end
-- do calculations and determine strings to go in cells
function p.
-- iterate through potions
Line 65 ⟶ 75:
-- sanitise data, set to 0 if its not there
local lvl = item.lvl or
local buy = item.buy or 0
local sell = item.sell or 0
local brewXP = item.brewXP or 0
Line 75 ⟶ 86:
-- direct values
item.profit = sell -
item.XP = brewXP + prepXP
item.KP = brewKP + prepKP
Line 91 ⟶ 102:
item.profitPerHour = math.floor(item.profit * item.potionPerHour)
--
item.hasProfit = item.hasBuy and item.hasSell
item.hasXP = param.has_content(item.brewXP) and param.has_content(item.prepXP)
item.hasKP = param.has_content(item.brewKP) and param.has_content(item.prepKP)
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.
end
if
item.
else
item.
end
if item.hasXP and item.hasDuration then
item.
else
item.
end
if item.hasKP and item.hasDuration then
item.
else
item.
end
Line 156 ⟶ 145:
function p.displayTable(results)
local out =
:addClass('wikitable sortable')
:tag('tr')
:tag('th')
:wikitext('[[File:Alchemist small icon.png|15px]] Level')
:done()
:tag('th')
:wikitext('Potion')
:done()
:tag('th')
:wikitext('Reagents (plus bottle)')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Buy Value')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Sell Value')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/hr')
:done()
:tag('th')
:wikitext('XP')
:done()
:tag('th')
:wikitext('XP/hr')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Coins/XP')
:done()
--:tag('th')
-- :wikitext('KP')
--:done()
--:tag('th')
-- :wikitext('KP/hr')
--:done()
:done()
for i,item in ipairs(results) do
-- need to generate the text for the reagent cell before starting the row
local reagentCell = ''
for j, reagent in ipairs(item.reagents) do
end
out
:tag('tr')
:tag('td')
:css{ ['text-align'] = 'center' }
:done()
:tag('td')
:wikitext('[[File:' .. item.name .. '.png|30px|link=' .. item.name .. ']] [[' .. item.name .. ']]')
:done()
:tag('td')
:wikitext(reagentCell)
:done()
:wikitext(currency_cell(item.buy,item.hasBuy))
:wikitext(currency_cell(item.sell,item.hasSell))
:wikitext(currency_cell(item.profit,item.hasProfit))
:wikitext(currency_cell(item.profitPerHour,item.hasProfit and item.hasDuration))
:tag('td')
:wikitext(item.XP)
:done()
:tag('td')
:wikitext(item.XPPerHour)
:done()
:wikitext(currency_cell(item.profitPerXP,item.hasXP and item.hasProfit))
--:tag('td')
-- :wikitext(item.KP)
--:done()
--:tag('td')
-- :wikitext(item.KPPerHour)
--:done()
:done()
end
return out
end
|