Module:Sports table

This is an old revision of this page, as edited by CRwikiCA (talk | contribs) at 16:54, 15 September 2014 (More comment). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- Module to build tables for standings in football
-- Undocumented sandbox version now

local p = {}
 
-- Main function
function p.main(frame)
	-- Declare locals
	local Args = frame.args
	local N_teams = 0
	local t = {}
	local team_list = {}
	
	-- Read in number of consecutive teams (ignore entries after skipping a spot)
	while Args['team'..N_teams+1] ~= nil do
		N_teams = N_teams+1
		-- Sneakily add it twice to the team_list parameter, once for the actual
		-- ranking, the second for position lookup in sub-tables
		team_list[N_teams] = Args['team'..N_teams] -- i^th entry is team X
		team_list[Args['team'..N_teams]] = N_teams -- team X entry is position i
	end
	
	-- Write column headers
	
	
	
	
	
	-- Close table
	table.insert(t, '|}<br>')
	
	-- Small text, footnotes
	table.insert(t, '<small>RESERVED TEXT</small>\n')
	
	
	-- START TEST CODE
	table.insert(t, team_list[N_teams]..'='..Args[team_list[N_teams]])
	local test1 = Args['test1'] or 'TEST_VAR'
	table.insert(t, '<br>'..test1..'<br>')
	table.insert(t, Args['team1']..'\n')
	table.insert(t, 'Test line just before return statement')
	-- END TEST CODE
	return table.concat( t, '\n' )
end
 
return p