Module:Sports table/CricketRR explained

-- Style for cricket tableslocal pp =

local function args_points(Args) local pts =

-- Do not change these defaults without first checking which tables use them pts.win = tonumber(Args['winpoints']) or 2 pts.tie = tonumber(Args['tiepoints']) or 1 pts.nr = tonumber(Args['nrpoints']) or 1 pts.loss = tonumber(Args['losspoints']) or 0 pts.bonus = tonumber(Args['bonuspoints']) or 1

return ptsend

local function abbr_header(txt, abbr, show_header_pts, pts) if show_header_pts then txt = txt .. ' – ' .. pts .. (pts

1 and ' point' or ' points') end

return '' .. abbr .. ''end

function pp.header(t, Args, p_sub, pos_label, group_col, VTE_text, full_table, results_header_txt) -- Load relevant modules local yesno = require('Module:Yesno') -- Create table header -- Pre stuff

local team_width = Args['teamwidth'] or '180' local sort_text = yesno(Args['sortable_table'] or 'no') and ' sortable' or

table.insert(t,'

style="'..ii_fw..bg_col..'"
'..matches..'\n') -- Played

if full_table then -- Use actual values if wins, ties, and losses are not numeric. Copied this from other module. if (wins

0 and ties

0 and losses

0) then local function numorval(s) return s and((s

and 0) or tonumber(s) or s) or 0 end wins = numorval(Args['win_'..team_code_ii]) ties = numorval(Args['tie_'..team_code_ii]) losses = numorval(Args['loss_'..team_code_ii]) end table.insert(t,'

'..wins..win_string..'\n') -- Won if loss_first then table.insert(t,''..losses..'\n') -- Lost if show_tie then table.insert(t,''..ties..'\n') -- Ties end else if show_tie then table.insert(t,''..ties..'\n') -- Ties end table.insert(t,''..losses..'\n') -- Lost end if show_nr then table.insert(t,''..noresults..'\n') -- No Results end if show_bonus_points then if s_bps< 0 then table.insert(t,'-'..-s_bps..'\n') else table.insert(t,''..s_bps..'\n') end end if show_deduct then table.insert(t,''..deductions..'\n') end end if points<0 then table.insert(t,'-'..-points..pts_string..'\n') else table.insert(t,''..points..pts_string..'\n') end if full_table then if show_nrr then table.insert(t,''..nrr..'\n') -- Net run rate end if show_nrr_fa then local nrr_for_text = oversreceived > 0 and runsscored..'/'..oversreceived or ' - ' local nrr_against_text = oversbowled > 0 and runsconceded..'/'..oversbowled or ' - ' table.insert(t, 'data-sort-value="'..nrr_for..'" style="'..ii_fw..bg_col..'" '..nrr_for_text..'\n') table.insert(t, 'data-sort-value="'..nrr_against..'" style="'..ii_fw..bg_col..'" '..nrr_against_text..'\n') end end

return end

function pp.status(Args) -- Declare status options -- ------------------------------------------------------------ -- NOTE: If you add to status_code, also add to status_called and status_letters!

-- Or functionality will be compromised -- ------------------------------------------------------------ local status_code, status_called =,

status_code = local status_letters = (Args['status_order'] or ) .. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

-- Status position(before or after read and default)

local stat_pos_val = string.lower(Args['status_pos'] or ) local status_position = 'after'-- Default location if stat_pos_val

'before' then status_position = 'before' elseif stat_pos_val

'after' then status_position = 'after' end for l in mw.text.gsplit(status_letters, ) do status_called[l] = false status_code[l] = status_code[l] or '?' status_letters = mw.ustring.gsub(status_letters, '(' .. l..'.-)' .. l, '%1')

if Args['status_text_'..l] then status_code[l] = Args['status_text_'..l] end end return end

return pp