Module:Set list

--   Var list:    (so I can keep track of what to use)    Set:    ->  PAGENAME            //  ;    ->  NAMESPACE           //  ;    ->  _rg                 //  Region code;    ->  _region             //  Region name;    ->  _ln                 //  Language code;    ->  _language           //  Language name;    ->  nameSet_parts       //  Aux var containing the parts for the set name by «(»;    ->  _nameSet            //  Set name;    ->  _nameSet_localized  //  Localized set name;    ->  _qty                //  Quantity value;    Design:    ->  header              //  Page header (HTML);    ->  category            //  Category;    ->      Flags:    ->  notEnglish          //  Boolean;    ->  italics             //  Italicized name;    ->  qty                 //  Boolean: exists ;    ->  noAbbr              //  Boolean: if  is set off;    ->   -- --  Start: -- local myInput = {}; --  Load outside data and modules: local data = mw.loadData( 'Module:Set list/data' ); local LN = require( 'Module:Set list/name' );  --  For Localized Name.

function myInput.list( frame ) -- Get arguments: -- { '1', 'region', 'set', 'qty', 'abbr', 'col', 'header', 'rarity' } local parameters = frame.args; -- Load outside data: local rg_list      = data.rg_list; local region_list  = data.region_list; local ln_list      = data.ln_list; local language_list = data.language_list; --     local PAGENAME = mw.title.getCurrentTitle.text; --     local NAMESPACE = mw.title.getCurrentTitle.nsText; -- Define vars related to the set info: -- Region and language: local _rg = parameters['region'] and parameters['region']:lower; local _region = ''; if _rg == nil or _rg == '' then --_region = string.match( PAGENAME, '%-(%a*)' ):lower; -- a value is needed always! return ' Error: A «region» is always needed! ';   else _region = region_list[_rg] or region_list['default']; end local flag_notEnglish = true; local flag_italics = 'italic'; local _ln = ln_list[_rg]; local _language = language_list[_ln]; if _ln == 'en' then flag_notEnglish = false; end if _ln == 'ja' or _ln == 'zh' or _ln == 'ko' then flag_italics = 'normal'; end

-- Set name: local _nameSet = parameters['set']; if _nameSet == nil or _nameSet == '' then local nameSet_parts = mw.text.split( PAGENAME, ' %(' );       if nameSet_parts[3] == nil or nameSet_parts[3] == '' then            _nameSet = nameSet_parts[1];  -- Set name doesn't contain dab text.        else            _nameSet = nameSet_parts[1] ..' ('.. nameSet_parts[2]; -- Set name contains dab text. end end local _nameSet_localized = LN.localized_name( _nameSet, _language ); -- Set abbreviation: local _abbr = parameters['abbr'] and parameters['abbr']:lower; local flag_noAbbr = false; if _abbr == 'no' or _abbr == 'none' or _abbr == 'off' or _abbr == 'false' or _abbr == '0' then flag_noAbbr = true; end -- Quantity (main): local _qty = parameters['qty']; -- $qty-value local flag_qty = false; if not(_qty == nil or _qty == '') then flag_qty = true; _qty = tonumber(_qty) or 1; end ---   --  Design page header: ---   local header = mw.html.create( 'div' ):css('text-align', 'center') :tag('span'):css{ ['font-size']  = '120%', ['font-weight'] = 'bold', ['font-style'] = 'italic' }           :wikitext( .._nameSet.. ) :done if flag_notEnglish and _nameSet_localized then header:tag('br') :tag('span'):css{ ['font-weight'] ='bold', ['font-style'] = flag_italics }               :wikitext(_nameSet_localized) :done end header:tag('br') :wikitext(_region) :allDone

local category = string.format('', _region, NAMESPACE) -- For debug. local out = mw.html.create( 'ul' ) :tag('li'):tag('code'):wikitext('PAGENAME'):done:wikitext(': '..PAGENAME):done :tag('li'):tag('code'):wikitext('NAMESPACE'):done:wikitext(': '..NAMESPACE):done :tag('li'):tag('code'):wikitext('_rg'):done:wikitext(': '.._rg):done :tag('li'):tag('code'):wikitext('_region'):done:wikitext(': '.._region):done :tag('li'):tag('code'):wikitext('_ln'):done:wikitext(': '.._ln):done :tag('li'):tag('code'):wikitext('_language'):done:wikitext(': '.._language):done :tag('li'):tag('code'):wikitext('_nameSet'):done:wikitext(': '.._nameSet):done :tag('li'):tag('code'):wikitext('_nameSet_localized'):done:wikitext(': '.._nameSet_localized):done :tag('li'):tag('code'):wikitext('_qty'):done:wikitext(': '..tostring(_qty)):done :tag('li'):tag('code'):wikitext('flag_notEnglish'):done:wikitext(': '..tostring(flag_notEnglish)):done :tag('li'):tag('code'):wikitext('flag_italics'):done:wikitext(': '..flag_italics):done :done return tostring(out)..tostring(header)..category; --the set list page; end

return myInput;