FANDOM


-- <pre>
local p = {}
 
local hasc = require('Module:Paramtest').has_content
 
local left_pos = {
	'5px',
	'2px',
	'-1px',
	'-5px'
}
 
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
	return p._main(items,acss)
end
 
function p._main(items,acss)
	local ret = mw.html.create('table')
				:addClass('inventorytable')
				:cssText(acss or '')
 
	local item = 0
	for i=1,7 do
		local ret_row = mw.html.create('tr')
		for j=1,4 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 = mw.html.create('span')
								:css({ ['font-family'] = 'runescape-small',
									['font-size'] = '16px',
									position = 'absolute',
									top = '-1px',
									left = '6px',
									color = 'yellow',
									['text-shadow'] = '#000 1px 1px' })
								:wikitext(amtx)
							:done()
					item_text = tostring(amt_span)
				end
 
				item_text = item_text .. '[[File:'..itemx..'.png|link='..itemx..']]'
			end
			ret_row:tag('td')
					:css({left = left_pos[j] })
					:wikitext(item_text)
				:done()
		end
		ret:node(ret_row)
	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.