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

Module:Statistics: Difference between revisions

From PC Gaming Shelter
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(..."
 
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
local itemValue = args[2] or '100%'
local itemValue = args[2] or '100%'
local itemTarget = args['target'] or nil
local itemTarget = args['target'] or nil
local itemClass = args['class'] or 'shelter-stats-item'
local itemClass = args['class'] or ''
local itemImage = args['image'] or 'Shelter.png'
local itemImage = args['image'] or 'Shelter.png'
local itemImageUrl = frame:preprocess(
local itemImageUrl = frame:preprocess(
Line 13: Line 13:
local itemString = ''
local itemString = ''
if itemTarget then
if itemTarget ~= nil then
itemString = string.format('[[%s|%s]]:', itemTarget, itemName)
itemString = string.format('[[%s|%s]]', itemTarget, itemName)
else
else
itemString = string.format('%s:', itemName)
itemString = string.format('%s', itemName)
end
end
local html = mw.html.create()
local html = mw.html.create()
html:tag('div'):addClass(itemClass)
html:tag('div'):addClass(string.format('shelter-stats-item %s', itemClass))
:tag('div'):attr('data-bg', itemImageUrl):done()
:tag('div'):addClass('shelter-stats-item-icon'):attr('data-bg', itemImageUrl):done()
:tag('div'):addClass(shelter-stats-item-name):wikitext(itemString):done()
:tag('div'):addClass('shelter-stats-item-name'):wikitext(itemString):done()
:tag('div'):addClass(shelter-stats-item-value):wikitext(itemValue):done()
:tag('div'):addClass('shelter-stats-item-value'):wikitext(itemValue):done()
:done()
:done()
return html
return html

Latest revision as of 11:20, 15 March 2026

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 ''
	local itemImage = args['image'] or 'Shelter.png'
	local itemImageUrl = frame:preprocess(
		string.format('{{filepath:{{PAGENAME:%s}}}}', itemImage)
	)
	
	local itemString = ''
	if itemTarget ~= nil then
		itemString = string.format('[[%s|%s]]', itemTarget, itemName)
	else
		itemString = string.format('%s', itemName)
	end
	
	local html = mw.html.create()
	html:tag('div'):addClass(string.format('shelter-stats-item %s', itemClass))
		:tag('div'):addClass('shelter-stats-item-icon'):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