FANDOM


-- <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')
					: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)..'&nbsp;<small>&#91;[[Exchange:'..ret_name..'|graph]]&#93;</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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.