Documentation for this module may be created at Module:GE cost table/doc
-- <pre>
-- Implements [[Template:GE Set Cost Table]]
--
local p = {}
local is_empty = require('Module:Paramtest').is_empty
local coins = require('Module:Coins')._amount
local gep = require('Module:Exchange')._price
function p.make_table( frame )
local parameters = frame:getParent().args
local set_name = parameters['set'] or ''
local ret = mw.html.create('table')
:addClass('wikitable GE-set-cost')
:tag('caption')
:wikitext(set_name..' Grand Exchange cost')
:done()
:css('margin','0')
:done()
local function make_row(builder,item_name, item_image, item_price, item_qty)
local ret_name = item_name
local ret_image
local ret_price
if item_image then
ret_image = '[[File:'..item_image..']]'
else
ret_image = '[[File:'..ret_name..'.png]]'
end
if item_price then
ret_price = item_price
else
ret_price = gep(ret_name)
end
builder:tag('tr')
:tag('td')
:css('text-align','center')
:wikitext(ret_image)
:done()
:tag('td')
:wikitext('[['..ret_name..']]' .. ((item_qty > 1) and (' × ' .. item_qty) or ''))
:done()
:tag('td')
:css('text-align','right')
:attr('title', (item_qty > 1) and (ret_price .. ' coins each') or '')
:wikitext(tonumber(ret_price) and (coins(ret_price * item_qty)..' <small>[[[Exchange:'..ret_name..'|graph]]]</small>') or ret_price)
:done()
:done()
end
local total_price = 0
for i=1,20 do
local rt_name = parameters['name'..i]
local rt_price = parameters['price'..i]
local rt_image = parameters['image'..i]
local rt_qty = tonumber(parameters['qty'..i]) or 1
if rt_name then
make_row(ret,rt_name,rt_image,rt_price,rt_qty)
if not rt_price then
total_price = total_price + gep(rt_name) * rt_qty
end
end
end
if not parameters.notot then
ret:tag('tr')
:tag('th')
:attr('colspan','2')
:wikitext('Total price')
:done()
:tag('td')
:css({ background = '#F0F0F0',
['text-align'] = 'right' })
:wikitext(coins(total_price))
:done()
:done()
end
return ret
end
return p
Community content is available under CC-BY-SA unless otherwise noted.