Module:PotionList: Difference between revisions

m
Remove unused vars
(Undo revision 49590 by Artoire (talk): Sorting breaks up cells with rowspan)
Tag: Undo
m (Remove unused vars)
Line 1:
require('strict')
require('Module:Mw.html extension')
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local lang = mw.getContentLanguage()
require("Module:Mw.html extension")
 
 
local p = {}
Line 10 ⟶ 9:
-- non dynamic module, no inputs
function p.main()
 
-- returns almost every parameter needed for the row, except buy values for reagents
local query = {
Line 53 ⟶ 51:
 
-- iterate through potions
for i_, item in ipairs(results) do
 
--in case of single reagent potions, make table of 1 element
Line 63 ⟶ 61:
-- starting value 20 is for bottle
item.buy = 20
for j_, reagent in ipairs(item.reagents) do
 
--shamelessley lifted from Module:Products
Line 76 ⟶ 74:
item.buy = item.buy + shopPrice
end
 
-- 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
local prepXP = item.prepXP or 0
local brewKP = item.brewKP or 0
local prepKP = item.prepKP or 0
local brewDuration = item.brewDuration or 0
local prepDuration = item.prepDuration or 0
 
-- direct values
Line 111 ⟶ 98:
-- make the table
function p.displayTable(results)
 
local out = mw.html.create('table')
:addClass('wikitable sortable')
Line 151 ⟶ 137:
: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
reagentCell = reagentCell .. '[[File:' .. reagent .. '.png|30px|link=' .. reagent .. ']] [[' .. reagent .. ']]<br>'
end
 
local unknown_value_cell = mw.html.create('td')
Line 166 ⟶ 143:
:wikitext("''unknown''")
 
for i, item in ipairs(results) do
out
local row = out:tag('tr')
:IF(item.lvl)
:tag('td')
Line 181 ⟶ 158:
:done()
 
local reagentCell = row:tag('td')
:wikitext(reagentCell)
:done()
 
:wikitext(currency_cellfor j, reagent in ipairs(item.buy)reagents) do
reagentCell = reagentCell .. :wikitext('[[File:' .. reagent .. '.png|30px|link=' .. reagent .. ']] [[' .. reagent .. ']]<br>')
end
 
row
:wikitext(currency_cell(item.buy))
:wikitext(currency_cell(item.sell))
 
:wikitext(currency_cell(item.profit))
 
:wikitext(currency_cell(item.profitPerHour))
 
Line 212 ⟶ 189:
 
:done()
 
end
 
351

edits