Module:Sandbox/Frietjes

This is an old revision of this page, as edited by Frietjes (talk | contribs) at 17:28, 1 November 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p.main(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame, {parentFirst = true})
	
	local team_list = {}
	local ii = 1
	while args['team'..ii] ~= nil do
		team_list[args['team'..ii]] = ii
		ii = ii + 1
	end
	local max_team = ii - 1
	
	local first_team, last_team = 1, max_team
	if args['showteam'] and team_list[args['showteam']] then
		first_team = team_list[args['showteam']] - 2
		last_team = first_team + 4
		if first_team < 1 then
			first_team = 1
			last_team = first_team + 4
		end
		if last_team > max_team then
			last_team = max_team
			first_team = max_team - 4
		end
		if first_team < 1 then first_team = 1 end
	end
		
	local hasnotes = false
	
	local ii = first_team
	local res = '{| class="wikitable"\n'
	while args['team'..ii] ~= nil and (ii <= last_team) do
		res = res .. '|-\n'
		res = res .. '| ' .. args['team' .. ii] .. '\n'
		local text_result = args['result'..ii] and args['text_'..args['result'..ii]] or ''
		if text_result:match('fbmulticompefn') then
			hasnotes = true
		end
		res = res .. '| ' .. text_result .. '\n'
	end
	res = res .. '|}'
	
	if hasnotes == true then
		res = res .. frame:expandTemplate{ title = 'notelist'}
	end
	
	-- Generate tracking
	if not args['notracking'] then
		local getTracking = require('Module:Sports table/argcheck/sandbox').check
		local tracking_categories = getTracking(args, frame:getParent().args)
	end
end

return p