Module:Wheelchair rugby league match squad/sandbox explained

--local getArgs = require('Module:Arguments').getArgslocal p=--functionsfunction p.main(frame) local args = getArgs(frame) local collapsed = args['collapsed'] or 'n' -- decide if table is collapsible or no local align = args['align'] or 'right' -- table alignment on page (left, right or center, defaults to right if not set) align = string.lower(align) --convert to lower case local squadsize = args['squadsize'] or 10 --number of players to list if tonumber(squadsize) > 10 then squadsize = 10 --maximum squadsize allowed end --teams local hometeam = args['hometeam'] local awayteam = args['awayteam'] --and colours for header rows local homeBGcolour = args['homeBGcolour'] or 'white' local homeFGcolour = args['homeFGcolour'] or 'black' local homeBorder = args['homeBorder'] or 'none' local awayBGcolour = args['awayBGcolour'] or 'white' local awayFGcolour = args['awayFGcolour'] or 'black' local awayBorder = args['awayBorder'] or 'none' --set styles for home and away teams. Default is black text on white backgound with no border. local homestyle = 'style= \"border:2px solid ' .. homeBorder .. ';background:' .. homeBGcolour .. '; color:' .. homeFGcolour .. ';\"' local awaystyle = 'style= \"border:2px solid ' .. awayBorder .. ';background:' .. awayBGcolour .. '; color:' .. awayFGcolour .. ';\"'

--set positions local pos_1 = "Starter" local pos_2 = "Starter" local pos_3 = "Starter" local pos_4 = "Starter" local pos_5 = "Starter" local pos_6 = "Interchange" local pos_7 = "Interchange" local pos_8 = "Interchange" local pos_9 = args['titleIN4'] or "Interchange" local pos_10 = args['titleIN5'] or "Interchange"

--Home players local hplayer_1 =args['homeStart1'] or "" local hplayer_2 =args['homeStart2'] or "" local hplayer_3 =args['homeStart3'] or "" local hplayer_4 =args['homeStart4'] or "" local hplayer_5 =args['homeStart5'] or "" local hplayer_6 =args['homeIN1'] or "" local hplayer_7 =args['homeIN2'] or "" local hplayer_8 =args['homeIN3'] or "" local hplayer_9 =args['homeIN4'] or "" local hplayer_10 =args['homeIN5'] or "" local hcoach = args['homeCoach'] or "" -- Home team numbers local hnumber_1 =args['homeStart1num'] or '1' local hnumber_2 =args['homeStart2num'] or '2' local hnumber_3 =args['homeStart3num'] or '3' local hnumber_4 =args['homeStart4num'] or '4' local hnumber_5 =args['homeStart5num'] or '5' local hnumber_6 =args['homeIN1num'] or '6' if hplayer_6

"" then hnumber_6 = "" end local hnumber_7 =args['homeIN2num'] or '7' if hplayer_7

"" then hnumber_7 = "" end local hnumber_8 =args['homeIN3num'] or '8' if hplayer_8

"" then hnumber_8 = "" end local hnumber_9 =args['homeIN4num'] or '9' if hplayer_9

"" then hnumber_9 = "" end local hnumber_10 =args['homeIN5num'] or '10' if hplayer_10

"" then hnumber_10 = "" end

--Away players local aplayer_1 =args['awayStart1'] or "" local aplayer_2 =args['awayStart2'] or "" local aplayer_3 =args['awayStart3'] or "" local aplayer_4 =args['awayStart4'] or "" local aplayer_5 =args['awayStart5'] or "" local aplayer_6 =args['awayIN1'] or "" local aplayer_7 =args['awayIN2'] or "" local aplayer_8 =args['awayIN3'] or "" local aplayer_9 =args['awayIN4'] or "" local aplayer_10 =args['awayIN5'] or "" local acoach = args['awayCoach'] or ""

-- Away team numbers local anumber_1 =args['awayStart1num'] or '1' local anumber_2 =args['awayStart2num'] or '2' local anumber_3 =args['awayStart3num'] or '3' local anumber_4 =args['awayStart4num'] or '4' local anumber_5 =args['awayStart5num'] or '5' local anumber_6 =args['awayIN1num'] or '6' if aplayer_6

"" then anumber_6 = "" end local anumber_7 =args['awayIN2num'] or '7' if aplayer_7

"" then anumber_7 = "" end local anumber_8 =args['awayIN3num'] or '8' if aplayer_8

"" then anumber_8 = "" end local anumber_9 =args['awayIN4num'] or '9' if aplayer_9

"" then anumber_9 = "" end local anumber_10 =args['awayIN5num'] or '10' if aplayer_10

"" then anumber_10 = "" end --sourcing local source = args['source'] or "" --fill table local hplayer local hnumber local pos local aplayer local anumber

local t = --check for 00 values in player numbers and replace with "". This allows players to show as unnmbered in teams using squad numbers e.g. trialists for trow = 1, 10 do if t[trow].hnumber

"00" then t[trow].hnumber = "" end if t[trow].anumber

"00" then t[trow].anumber = "" end end --create table local wt= --main output string. Loops through the table t to extract info by positions for i = 1, squadsize do wt = wt .. t[i].hplayer .. '||' .. t[i].hnumber .. '|| style=\"background:#eee;\"|' .. t[i].pos .. '||' .. t[i].anumber .. '||' .. t[i].aplayer .. '\n|-\n|' end --add coaches if one or both is named if hcoach ~="" or acoach~="" then wt = wt .. t[11].hplayer .. '||' .. t[11].hnumber .. '|| style=\"background:#eee;\"|' .. t[11].pos .. '||' .. t[11].anumber .. '||' .. t[11].aplayer .. '\n|-\n|' end -- table headings. Set depending of page alignment (left, right or center) local table_style = "" if align

'right' then table_style = ' style=\"float:right; font-size:90%; margin-left:1em; text-align:center;\"' end if align

'left' then table_style = ' style=\"float:left; font-size:90%; margin-right:1em; text-align:center;\"' end if align

'center' then table_style = ' style=\"margin-left: auto; margin-right: auto; border: none; font-size:90%; text-align:center;\"' end local definition_row = '

' .. caption ..'\n!' .. header_row1 .. '\n' .. header_row2 .. '\n'.. wt .. source_row .. '
' end return return_tendreturn p