Module:Video game release
Appearance
From Wikipedia, the free encyclopedia
This module depends on the following other modules:
Warning This Lua module is used on approximately 18,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page template-protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module implements the {{Video game release }} and {{Video game release hlist }} templates. The parameter "format" is passed to Module:List to set the output format. Please see the template page for usage instructions and tracking categories.
The above documentation is transcluded from Module:Video game release/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
require('strict') localgetArgs=require('Module:Arguments').getArgs localcd=require('Module:CountryData') locallist=require('Module:List'); localp={} localknownargs={ ['format']=true, ['class']=true, ['style']=true, ['list_style']=true, ['item_style']=true, ['item1_style']=true, ['indent']=true } locallabels={ ['NA']="[[North America|NA]]", ['EU']="[[Europe|EU]]", ['EUR']="[[Europe|EU]]", ['AU']="[[Australasia|AU]]", ['AUS']="[[Australasia|AU]]", ['PAL']="[[PAL region|PAL]]", ['SEA']="[[Southeast Asia|SEA]]", ['AS']="[[Asia|AS]]", ['SA']="[[South America|SA]]", ['OC']="[[Oceania|OC]]", ['WW']="<abbr title=\"Worldwide\">WW</abbr>" } localfunctiongetLocalLabel(alias) locallabel=labels[string.upper(alias)] returnlabel end localcountryData={};-- Used to store country data to avoid the need of repeated calls to Module:CountryData. This saves a little time if the same abbreviation appears multiple times in the template. localfunctiongetCountryData(frame,alias) localualias=string.upper(alias) if(countryData[ualias]==nil)then localcdtable=cd.gettable(frame,alias,{}) countryData[ualias]=cdtable['alias'] end returncountryData[ualias] end localfunctionsplitLabel(s) localislist=true localres={} fork,vinipairs(mw.text.split(sor'','%s*/%s*'))do localv1=v:match('^%s*([A-Z][A-Z][A-Z]?)%s*$') ifv1then table.insert(res,v1) else localv2=v:match('^%s*(%[%[[^%[%]|]*|[A-Z][A-Z][A-Z]?%]%])%s*$') ifv2then table.insert(res,v2) else islist=false end end end returnislistandresor{s} end functionp.main(frame) localargs=getArgs(frame) locallistformat=args['format'] if(listformat==nilorlistformat=="")then listformat="unbulleted" end localitems={} -- Old syntax "Two parameter region" use case, where param 1 is an article, param 2 is a label, and param 3 is the date. We assume this case if argument 4 is nil. if(args[3]~=nilandargs[4]==nil)then localitem="<span style=\"font-size:97%;\">[[" if(args[1]~=nil)then item=item..args[1] end item=item.."|" if(args[2]~=nil)then item=item..args[2] end item=item.."]]:</span> "..args[3].."[[Category:Pages using vgrelease with two parameter region]]" table.insert(items,item) -- Old syntax "Blank region" use case, where param 1 is empty, and param 2 is the date. elseif(args[1]==nilandargs[2]~=nil)then localitem=args[2].."[[Category:Pages using vgrelease without a region]]" table.insert(items,item) -- Normal use cases, region/date pairs in 1/2, 3/4, 5/6, etc. else locali=1 localj=2 while(args[i]andargs[j])do locallabels={} fork,vinipairs(splitLabel(args[i]))do locallabel=getLocalLabel(v); -- Didn't find a local label? Check for country data. if(label==nil)then ifnotv:match('^%s*%[')then label=getCountryData(frame,v) end -- Found something? Build a sitelink with it. if(label~=nil)then label="[["..label.."|"..v.."]]" else label=v end end table.insert(labels,label) end localitem="<span style=\"font-size:97%;\">"..table.concat(labels,'/')..":</span> "..args[j] table.insert(items,item) i=i+2 j=j+2 end end -- Add known parameters of Module:List to the table fork,vinpairs(args)do if(knownargs[k]==true)then items[k]=v end end localout=list.makeList(listformat,items) -- Preview message and category localparameterMsg=require('Module:If preview')._warning({ 'Unknown parameter "_VALUE_".' }).."[[Category:Pages using vgrelease with named parameters|_VALUE_]]" -- Check for invalid parameters fork,vinpairs(args)do if(type(k)~='number'andknownargs[k]~=true)then localmsg=parameterMsg:gsub('_VALUE_',k) out=out..msg end end returnout end returnp