Jump to content

Module:NPVIC status

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Swpb (talk | contribs) at 14:08, 18 May 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.states(frame)
	local states = frame.args[1]
	local total = 0
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		if state~='DC' then
			total = total + 1
		end
	end
	return total
end

function p.EVs(frame)
	local states = frame.args[1]
	local total = 0
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		seats = frame:expandTemplate{ title = 'USHRseats', args = { state } }
		if type(tonumber(seats))=='nil' then
			total = error("Unrecognized state")
			break
		else
			total = total + seats + 2
		end
	end
	return total
end

function p.overlay(frame)
	local states = frame.args[1]
	local color = frame.args[2]
	local size = frame.args[3]
	local overlays = ''
	
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		state_overlay = '<div style=\"position: absolute; left: 0px; top: 0px\">[[File:' .. state .. ' ' .. color .. '.svg|' .. size .. ']]</div>'
		overlays = overlays .. state_overlay
	end
	return overlays
end

return p