Module:Sports table/WDLHA/sandbox explained

-- Style for football tableslocal pp =

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 '190' local sort_text = yesno(Args['sortable_table'] or 'no') and ' sortable' or local show_played = not yesno(Args['hide_played'] or 'no') local rounds_won = yesno(Args['show_rw'] or Args['rounds_won'] or 'no') table.insert(t,'

style="'..ii_fw..bg_col..'"
'..matches..'\n') -- Played end if full_table then -- Use actual values if wins, draws, and losses are not numeric if (hwins

0 and awins

0 and hdraws

0 and adraws

0 and hlosses

0 and alosses

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

and 0) or tonumber(s) or s) or 0 end hwins = numorval(Args['hwin_'..team_code_ii]) awins = numorval(Args['awin_'..team_code_ii]) hdraws = numorval(Args['hdraw_'..team_code_ii]) adraws = numorval(Args['adraw_'..team_code_ii]) hlosses = numorval(Args['hloss_'..team_code_ii]) alosses = numorval(Args['aloss_'..team_code_ii]) end local stats = only_totals and or for k,v in ipairs(stats) do table.insert(t,'

'..(v[1])..win_string..'\n') -- Won if loss_first then table.insert(t,''..(v[3])..'\n') -- Lost if show_draw then table.insert(t,''..(v[2])..'\n') -- Drawn end else if show_draw then table.insert(t,''..(v[2])..'\n') -- Drawn end table.insert(t,''..(v[3])..'\n') -- Lost end if rounds_won then table.insert(t,''..(v[4])..'\n') -- Rounds won end if not hide_for_against and not only_fa_totals then table.insert(t,''..(v[5])..'\n') -- GF table.insert(t,''..(v[6])..'\n') -- GA end end if not hide_for_against then local lsps = sps if only_fa_totals then table.insert(t,''..gfor..'\n') -- GF table.insert(t,''..gaig..'\n') -- GA lsps = end table.insert(t,''..gcomp..'\n') -- Goal comparison end end if show_GB then table.insert(t,''..GB_text..'\n') -- GB end if rank_perc then table.insert(t,''..win_perc..hth_string..'\n') end if show_bonus_points then if s_pts < 0 then table.insert(t,'-'..-s_pts..'\n') else table.insert(t,''..s_pts..'\n') end end if rank_points then -- Add - for negative point totals if points<0 then table.insert(t,'-'..-points..hth_string..'\n') else table.insert(t,''..points..hth_string..'\n') end end if ha_side then local hrec = hwins .. '–' .. (show_draw and (loss_first and hlosses ..'–'..hdraws or hdraws ..'–'..hlosses) or hlosses) local arec = awins .. '–' .. (show_draw and (loss_first and alosses ..'–'..adraws or adraws ..'–'..alosses) or alosses) table.insert(t,''..hrec..'\n') table.insert(t,''..arec..'\n') 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 -- Read in custom status options 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