FANDOM


-- <pre>
local p = {}
 
local hasc = require('Module:Paramtest').has_content
 
function amount(amtx)
	local ret = mw.html.create('span')
	ret:css({ ['font-family'] = 'runescape-small',
			['font-size'] = '16px',
			position = 'absolute',
			top = '-1px',
			left = '6px',
			color = 'yellow',
			['text-shadow'] = '#000 1px 1px' })
		:wikitext(amtx)
		:done()
	return ret
end
 
 
function p.main(frame)
	local args = frame:getParent().args
	local items = {}
	for i=1,28 do
		local v = mw.text.trim(args[i] or '')
		local item_x
		local amt_x
		if hasc(v) then
			v = v:gsub('[][]','')
			if v:find('\\') then
				local v2 = mw.text.split(v,'\\')
				item_x = v2[1]
				amt_x = tonumber(v2[2])
			else
				item_x = v
			end
		end
		table.insert(items,{item=item_x,amt=amt_x})
	end
	local align = args.align
	local acss
	if hasc(align) then
		align = align:lower()
		if align == 'right' or align == 'left' then
			acss = 'float:'..align
		elseif align == 'center' then
			acss = 'margin:0 auto'
		end
	end
	local horiz = string.find(args.orient or '', '^%s*h') ~= nil
	return p._main(items,acss,horiz)
end
 
function p._main(items,acss,horiz)
	local ret = mw.html.create('table')
				:addClass('inventorytable')
				:cssText(acss or '')
 
	local row,col = 7, 4
	if horiz then
		row,col = 4, 7
		ret:addClass('inventorytable-horizontal')
	end
 
	local item = 0
	for i=1,row do
		local ret_row = mw.html.create('tr')
		for j=1,col do
			item = item + 1
			local itemx = items[item].item
			local amtx = items[item].amt
			local item_text = ''
			if hasc(itemx) then
				if amtx then
					local amt_span = amount(amtx)
					item_text = tostring(amt_span)
				end
 
				item_text = item_text .. '[[File:'..itemx..'.png|link='..itemx..']]'
			end
			ret_row:tag('td')
					:wikitext(item_text)
				:done()
		end
		ret:node(ret_row)
	end
 
	return ret
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.