Module:Rugby league match squad 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 18 --number of players to list if tonumber(squadsize) > 26 then squadsize = 26 --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 .. ';\"'

--postion names determined by hemisphere. Can be north (n), south (s) north/south (ns) or south/north (sn)-- local location = args['location'] location =string.lower(location) --convert to lower case local abbr = args['abbr'] or 'n' -- set to y to use abbreviated position names, default is n abbr = string.lower(abbr) -- convert to lower case if location ~= "n" and location ~= "s" and location ~= "ns" and location ~= "sn" then location = "n" --catchall end --define variable positions first local pos_6="" local pos_7="" local pos_13="" if location

"n" then pos_6 = "Stand off" pos_7 = "Scrum half" pos_13 = "Loose forward" if abbr

"y" then --abbreviated position names pos_6 = "SO" pos_7 = "SH" pos_13 = "LF" end elseif location

"s" then pos_6 = "Five eighth" pos_7 = "Half back" pos_13 = "Lock forward" if abbr

"y" then --abbreviated position names pos_6 = "FE" pos_7 = "HB" pos_13 = "LK" end elseif location

"ns" then pos_6 = "Stand off/Five eighth" pos_7 = "Scrum half/Half back" pos_13 = "Loose forward/Lock forward" if abbr

"y" then --abbreviated position names pos_6 = "SO/FE" pos_7 = "SH/HB" pos_13 = "LF/LK" end elseif location

"sn" then --abbreviated position names pos_6 = "Five eighth/Stand off" pos_7 = "Half back/Scrum half" pos_13 = "Lock forward/Loose forward" if abbr

"y" then --abbreviated position names pos_6 = "FE/SO" pos_7 = "HB/SH" pos_13 = "LK/LF" end end --set rest of positions local pos_1 = "Fullback" local pos_2 = "Wing" local pos_3 = "Centre" local pos_4 = "Centre" local pos_5 = "Wing" local pos_8 = "Prop forward" local pos_9 = "Hooker" local pos_10 = "Prop forward" local pos_11 = "Second row" local pos_12 = "Second row" local pos_14 = args['titleIN1'] or "Interchange" --allows for alternative position name local pos_15 = args['titleIN2'] or "Interchange" local pos_16 = args['titleIN3'] or "Interchange" local pos_17 = args['titleIN4'] or "Interchange" local pos_18 = args['titleIN5'] or "Concussion substitute" -- 18th player, can always be overwritten if pos_18

"Interchange" then pos_18 = "Interchange" -- autolink alternative position end local pos_19 = "Interchange" local pos_20 = "Interchange" local pos_21 = "Interchange" local pos_22 = "Interchange" local pos_23 = "Interchange" local pos_24 = "Interchange" local pos_25 = "Interchange" local pos_26 = "Interchange" if abbr

"y" then --abbreviated position names pos_1 = "FB" pos_2 = "WG" pos_3 = "CE" pos_4 = "CE" pos_5 = "WG" pos_8 = "PR" pos_9 = "HK" pos_10 = "PF" pos_11 = "SR" pos_12 = "SR" if pos_14

"Interchange" then --no abbreviation if title isn't Interchange pos_14 = "IN" end if pos_15

"Interchange" then pos_15 = "IN" end if pos_16

"Interchange" then pos_16 = "IN" end if pos_17

"Interchange" then pos_17 = "IN" end if pos_18

"Concussion substitute" then pos_18 = "CS" end if pos_18

"Interchange" then --alternative position linking pos_18 = "IN" end pos_19 = "IN" pos_20 = "IN" pos_21 = "IN" pos_22 = "IN" pos_23 = "IN" pos_24 = "IN" pos_25 = "IN" pos_26 = "IN" end --Home players local hplayer_1 =args['homeFB'] or "" local hplayer_2 =args['homeWG1'] or "" local hplayer_3 =args['homeCE1'] or "" local hplayer_4 =args['homeCE2'] or "" local hplayer_5 =args['homeWG2'] or "" local hplayer_6 =args['homeSO'] or "" local hplayer_7 =args['homeSH'] or "" local hplayer_8 =args['homePR1'] or "" local hplayer_9 =args['homeHK'] or "" local hplayer_10 =args['homePR2'] or "" local hplayer_11 =args['homeSR1'] or "" local hplayer_12 =args['homeSR2'] or "" local hplayer_13 =args['homeLF'] or "" local hplayer_14 =args['homeIN1'] or "" local hplayer_15 =args['homeIN2'] or "" local hplayer_16 =args['homeIN3'] or "" local hplayer_17 =args['homeIN4'] or "" local hplayer_18 =args['homeIN5'] or "" local hplayer_19 =args['homeIN6'] or "" local hplayer_20 =args['homeIN7'] or "" local hplayer_21 =args['homeIN8'] or "" local hplayer_22 =args['homeIN9'] or "" local hplayer_23 =args['homeIN10'] or "" local hplayer_24 =args['homeIN11'] or "" local hplayer_25 =args['homeIN12'] or "" local hplayer_26 =args['homeIN13'] or "" local hcoach = args['homeCoach'] or "" -- Home team numbers local hnumber_1 =args['homeFBnum'] or '1' local hnumber_2 =args['homeWG1num'] or '2' local hnumber_3 =args['homeCE1num'] or '3' local hnumber_4 =args['homeCE2num'] or '4' local hnumber_5 =args['homeWG2num'] or '5' local hnumber_6 =args['homeSOnum'] or '6' local hnumber_7 =args['homeSHnum'] or '7' local hnumber_8 =args['homePR1num'] or '8' local hnumber_9 =args['homeHKnum'] or '9' local hnumber_10 =args['homePR2num'] or '10' local hnumber_11 =args['homeSR1num'] or '11' local hnumber_12 =args['homeSR2num'] or '12' local hnumber_13 =args['homeLFnum'] or '13' --following lines set player number to blank if no name is given local hnumber_14 =args['homeIN1num'] or '14' if hplayer_14

"" then hnumber_14 = "" end local hnumber_15 =args['homeIN2num'] or '15' if hplayer_15

"" then hnumber_15 = "" end local hnumber_16 =args['homeIN3num'] or '16' if hplayer_16

"" then hnumber_16 = "" end local hnumber_17 =args['homeIN4num'] or '17' if hplayer_17

"" then hnumber_17 = "" end local hnumber_18 =args['homeIN5num'] or '18' if hplayer_18

"" then hnumber_18 = "" end local hnumber_19 =args['homeIN6num'] or '19' if hplayer_19

"" then hnumber_19 = "" end local hnumber_20 =args['homeIN7num'] or '20' if hplayer_20

"" then hnumber_20 = "" end local hnumber_21 =args['homeIN8num'] or '21' if hplayer_21

"" then hnumber_21 = "" end local hnumber_22 =args['homeIN9num'] or '22' if hplayer_22

"" then hnumber_22 = "" end local hnumber_23 =args['homeIN10num'] or '23' if hplayer_23

"" then hnumber_23 = "" end local hnumber_24 =args['homeIN11num'] or '24' if hplayer_24

"" then hnumber_24 = "" end local hnumber_25 =args['homeIN12num'] or '25' if hplayer_25

"" then hnumber_25 = "" end local hnumber_26 =args['homeIN13num'] or '26' if hplayer_26

"" then hnumber_26 = "" end

--Away players local aplayer_1 =args['awayFB'] or "" local aplayer_2 =args['awayWG1'] or "" local aplayer_3 =args['awayCE1'] or "" local aplayer_4 =args['awayCE2'] or "" local aplayer_5 =args['awayWG2'] or "" local aplayer_6 =args['awaySO'] or "" local aplayer_7 =args['awaySH'] or "" local aplayer_8 =args['awayPR1'] or "" local aplayer_9 =args['awayHK'] or "" local aplayer_10 =args['awayPR2'] or "" local aplayer_11 =args['awaySR1'] or "" local aplayer_12 =args['awaySR2'] or "" local aplayer_13 =args['awayLF'] or "" local aplayer_14 =args['awayIN1'] or "" local aplayer_15 =args['awayIN2'] or "" local aplayer_16 =args['awayIN3'] or "" local aplayer_17 =args['awayIN4'] or "" local aplayer_18 =args['awayIN5'] or "" local aplayer_19 =args['awayIN6'] or "" local aplayer_20 =args['awayIN7'] or "" local aplayer_21 =args['awayIN8'] or "" local aplayer_22 =args['awayIN9'] or "" local aplayer_23 =args['awayIN10'] or "" local aplayer_24 =args['awayIN11'] or "" local aplayer_25 =args['awayIN12'] or "" local aplayer_26 =args['awayIN13'] or "" local acoach = args['awayCoach'] or ""

-- Away team numbers local anumber_1 =args['awayFBnum'] or '1' local anumber_2 =args['awayWG1num'] or '2' local anumber_3 =args['awayCE1num'] or '3' local anumber_4 =args['awayCE2num'] or '4' local anumber_5 =args['awayWG2num'] or '5' local anumber_6 =args['awaySOnum'] or '6' local anumber_7 =args['awaySHnum'] or '7' local anumber_8 =args['awayPR1num'] or '8' local anumber_9 =args['awayHKnum'] or '9' local anumber_10 =args['awayPR2num'] or '10' local anumber_11 =args['awaySR1num'] or '11' local anumber_12 =args['awaySR2num'] or '12' local anumber_13 =args['awayLFnum'] or '13' --following lines set player number to blank if no name is given local anumber_14 =args['awayIN1num'] or '14' if aplayer_14

"" then anumber_14 = "" end local anumber_15 =args['awayIN2num'] or '15' if aplayer_15

"" then anumber_15 = "" end local anumber_16 =args['awayIN3num'] or '16' if aplayer_16

"" then anumber_16 = "" end local anumber_17 =args['awayIN4num'] or '17' if aplayer_17

"" then anumber_17 = "" end local anumber_18 =args['awayIN5num'] or '18' if aplayer_18

"" then anumber_18 = "" end local anumber_19 =args['awayIN6num'] or '19' if aplayer_19

"" then anumber_19 = "" end local anumber_20 =args['awayIN7num'] or '20' if aplayer_20

"" then anumber_20 = "" end local anumber_21 =args['awayIN8num'] or '21' if aplayer_21

"" then anumber_21 = "" end local anumber_22 =args['awayIN9num'] or '22' if aplayer_22

"" then anumber_22 = "" end local anumber_23 =args['awayIN10num'] or '23' if aplayer_23

"" then anumber_23 = "" end local anumber_24 =args['awayIN11num'] or '24' if aplayer_24

"" then anumber_24 = "" end local anumber_25 =args['awayIN12num'] or '25' if aplayer_25

"" then anumber_25 = "" end local anumber_26 =args['awayIN13num'] or '26' if aplayer_26

"" then anumber_26 = "" 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, 26 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[27].hplayer .. '||' .. t[27].hnumber .. '|| style=\"background:#eee;\"|' .. t[27].pos .. '||' .. t[27].anumber .. '||' .. t[27].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