PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Statistics

From PC Gaming Shelter
Revision as of 10:14, 15 March 2026 by WikiVisor (talk | contribs) (Created page with "local p = {} function p.item(frame) local args = frame:getParent().args local itemName = args[1] or 'Shelter' local itemValue = args[2] or '100%' local itemTarget = args['target'] or nil local itemClass = args['class'] or 'shelter-stats-item' local itemImage = args['image'] or 'Shelter.png' local itemImageUrl = frame:preprocess( string.format('{{filepath:{{PAGENAME:%s}}}}', itemImage) ) local itemString = '' if itemTarget then itemString = string.format(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Statistics/doc

local p = {}

function p.item(frame)
	local args = frame:getParent().args
	local itemName = args[1] or 'Shelter'
	local itemValue = args[2] or '100%'
	local itemTarget = args['target'] or nil
	local itemClass = args['class'] or 'shelter-stats-item'
	local itemImage = args['image'] or 'Shelter.png'
	local itemImageUrl = frame:preprocess(
		string.format('{{filepath:{{PAGENAME:%s}}}}', itemImage)
	)
	
	local itemString = ''
	if itemTarget then
		itemString = string.format('[[%s|%s]]:', itemTarget, itemName)
	else
		itemString = string.format('%s:', itemName)
	end
	
	local html = mw.html.create()
	html:tag('div'):addClass(itemClass)
		:tag('div'):attr('data-bg', itemImageUrl):done()
		:tag('div'):addClass(shelter-stats-item-name):wikitext(itemString):done()
		:tag('div'):addClass(shelter-stats-item-value):wikitext(itemValue):done()
	:done()
	return html
end	

return p