Module:Wheelchair rugby league match squad
Appearance
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected. |
Usage
[edit]This module uses TemplateStyles: |
This module is invoked by {{Wheelchair rugby league match squad}}. See the documentation page for that template on how to use the module.
--
local getArgs = require('Module:Arguments').getArgs
local p={}
--functions
function 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 9 --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 'inherit'
local homeFGcolour = args['homeFGcolour'] or 'inherit'
local homeBorder = args['homeBorder'] or 'none'
local awayBGcolour = args['awayBGcolour'] or 'inherit'
local awayFGcolour = args['awayFGcolour'] or 'inherit'
local awayBorder = args['awayBorder'] or 'none'
--set styles for home and away teams. Default is to inherit text and background colours from the stylesheet and border to none.
local homestyle = '<div class="homestyle"> style= \"border:2px solid ' .. homeBorder .. ';background:' .. homeBGcolour .. '; color:' .. homeFGcolour .. ';\"</div>'
local awaystyle = '<div class ="awaystyle"> style= \"border:2px solid ' .. awayBorder .. ';background:' .. awayBGcolour .. '; color:' .. awayFGcolour .. ';\"</div>'
--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 = {
{
hplayer = hplayer_1,
hnumber = hnumber_1,
pos = pos_1,
anumber = anumber_1,
aplayer = aplayer_1,
},
{
hplayer = hplayer_2,
hnumber = hnumber_2,
pos = pos_2,
anumber = anumber_2,
aplayer = aplayer_2,
},
{
hplayer = hplayer_3,
hnumber = hnumber_3,
pos = pos_3,
anumber = anumber_3,
aplayer = aplayer_3,
},
{
hplayer = hplayer_4,
hnumber = hnumber_4,
pos = pos_4,
anumber = anumber_4,
aplayer = aplayer_4,
},
{
hplayer = hplayer_5,
hnumber = hnumber_5,
pos = pos_5,
anumber = anumber_5,
aplayer = aplayer_5,
},
{
hplayer = hplayer_6,
hnumber = hnumber_6,
pos = pos_6,
anumber = anumber_6,
aplayer = aplayer_6,
},
{
hplayer = hplayer_7,
hnumber = hnumber_7,
pos = pos_7,
anumber = anumber_7,
aplayer = aplayer_7,
},
{
hplayer = hplayer_8,
hnumber = hnumber_8,
pos = pos_8,
anumber = anumber_8,
aplayer = aplayer_8,
},
{
hplayer = hplayer_9,
hnumber = hnumber_9,
pos = pos_9,
anumber = anumber_9,
aplayer = aplayer_9,
},
{
hplayer = hplayer_10,
hnumber = hnumber_10,
pos = pos_10,
anumber = anumber_10,
aplayer = aplayer_10,
},
-- add coaches as last row of array
{
hplayer = hcoach,
hnumber="",
pos = "Coach",
anumber="",
aplayer = acoach,
},
}
--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
-- <div class="position"> tags refer to formatting information used in <templatestyles> (see [[Module:Rugby league match squad/styles.css]])
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 .. '|| <div class="position">' .. t[i].pos .. '</div> ||' .. 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 .. '|| <div class="position">' .. t[11].pos .. '</div>||' .. t[11].anumber .. '||' .. t[11].aplayer .. '\n|-\n|'
end
-- table headings. Set depending of page alignment (left, right or center) and collapsed (yes/no)
local table_style = ""
if align == 'right' and collapsed == 'n' then
table_style = '{| class = "table_style_right"'
end
if align == 'left' and collapsed == 'n' then
table_style = '{| class = "table_style_left"'
end
if align == 'center' and collapsed == 'n' then
table_style = '{| class = "table_style_center"'
end
if align == 'right' and collapsed == 'y' then
table_style = '{| class = "table_style_right mw-collapsible mw-collapsed"'
end
if align == 'left' and collapsed == 'y' then
table_style = '{| class = "table_style_left mw-collapsible mw-collapsed"'
end
if align == 'center' and collapsed == 'y' then
table_style = '{| class = "table_style_center mw-collapsible mw-collapsed"'
end
local caption= '+ class=\"nowrap\" | <b>Team details</b>'
-- make teams first data row in table
local header_row1 = 'colspan=2 ' .. homestyle .. '|' .. hometeam .. '!! rowspan=2 <div class="position"> | Position !! colspan=2 </div>'
.. awaystyle .. '|' .. awayteam .. '\n|-\n'
-- header row
local header_row2 = 'Name !! Number !! Number !! Name \n|-\n'
-- last row is source
local source_row = 'colspan=5 | <div class="position">' ..source .. '</div> \n|'
-- put it all together
local return_t = table_style .. '\n|' .. caption ..'\n!' .. header_row1 .. '\n!' .. header_row2 .. '\n|'.. wt .. '}'
if source ~= "" then --only display source_row if it has content
return_t = table_style .. '\n|' .. caption ..'\n!' .. header_row1 .. '\n!' .. header_row2 .. '\n|'.. wt .. source_row .. '}'
end
return return_t
end
return p