Hierdie module is as beta beoordeel en is gereed vir wydverspreide gebruik. Dit is nog nuut en moet met versigtigheid gebruik word om te verseker dat die resultaat na verwagting is.
require('strict')localp={}localdata=mw.loadData('Module:MasterGunner/data')localgetArgs=require('Module:Arguments').getArgs-- South African Master Gunner Data-- Data Fields-- Code: This is just a duplicate of the lookup code, but expressed as a number instead of a string-- Rank: Person's rank. Not wikilinked--- FirstName: Initials or first name(s)-- Surname: Person's Surname-- Year: Year appointed Master Gunner-- WikiPage: If the person has a Wiki article, name of the article here-- PostNoms: list of Post Nominal Titles. Stored in Lua table format ie Curly braces with values separated by commas-- Post: The name of the post that they held when awarded. Commas will be turned into line breaks-- Note: Any additional info about this Gunner.-- RecipCat: Category for recipients. "List of Master Gunners (South Africa)"functionp.Gunner(frame)localoutput=''localtemplateArgs=getArgs(frame)localgunnercode=templateArgs["code"]ornil-- local pagename=templateArgs["pagename"] or nilifnotgunnercodethenoutput='<span style="color:#d33">Error: No code specified</span>'returnoutputendifdata[gunnercode]thenoutput=output..gunnercode..": "output=output..data[gunnercode].Code.." Meesterkanonieer van die artillerie".."<br />"output=output..data[gunnercode].FirstName.." "..data[gunnercode].Surname.." Year: "..data[gunnercode].Year.."<br />"returnoutputelseoutput='<span style="color:#d33">Error: code '..gunnercode..' not found</span>'endreturnoutputendfunctionp.GunnerBox(frame)localoutput=''localtemplateArgs=getArgs(frame)localgunnercode=templateArgs["code"]ornillocalimagesize=templateArgs["imagesize"]or'150px'ifnotgunnercodethenoutput='<span style="color:#d33">Error: No "code" specified. Use the Gunner number preceded by an A for example, code=A100</span>[[Category:Master Gunner Error]]'returnoutputendifdata[gunnercode]then-- Send Info-- Generate wiki table code for the Master Gunnerlocalfloat=templateArgs.floator'none'iffloat=="left"thenfloat="floatleft"elseiffloat=="right"thenfloat="floatright"endendiffloat=="none"thenfloat=''endlocaltableCode='{| class="wikitable '..float..'" style="text-align:center" \n'-- tableCode = tableCode .. "|+ Meesterkanonnier van die artillerie \n" -- CaptiontableCode=tableCode.."|-\n"tableCode=tableCode..'!colspan=2 style="background:red; color:white;"| Meesterkanonieer van die artillerie: '..data[gunnercode].Code..'\n'tableCode=tableCode.."|-\n"tableCode=tableCode.."|colspan=2|[[file:SANDF Arty Master Gunner badge embossed.png|border|"..imagesize.."|link=List of badges of the South African Army#Proficiency: Master Gunner| Meesterkanonnier van die artillerie]]\n"tableCode=tableCode.."|-\n"tableCode=tableCode.."|colspan=2|"..p.GetGunner("A"..data[gunnercode].Code)ifstring.len(data[gunnercode].Post)>1thentableCode=tableCode..mw.getCurrentFrame():expandTemplate{title='Efn',args={"Post occupied when award was made: "..data[gunnercode].Post}}endifstring.len(data[gunnercode].Note)>1thentableCode=tableCode..mw.getCurrentFrame():expandTemplate{title='Efn',args={data[gunnercode].Note}}endtableCode=tableCode.."\n"tableCode=tableCode.."|-\n "tableCode=tableCode.."|colspan=2|[[Meesterkanonnier van die artillerie (Suid-Afrika)|Year]]: '''"..data[gunnercode].Year.."'''\n"tableCode=tableCode.."|-\n"localprevgunner="A"..data[gunnercode].Code-1..""tableCode=tableCode.."| ←"..data[gunnercode].Code-1..": "..p.GetGunner(prevgunner).."\n"localnextgunner="A"..data[gunnercode].Code+1..""tableCode=tableCode.."| "..p.GetGunner(nextgunner).." :"..data[gunnercode].Code+1.."→\n"tableCode=tableCode.."|}"returntableCodeendreturnoutputendfunctionp.GetGunner(gunnercode)localoutput=''ifnotdata[gunnercode]thenoutput="Unknown"elseifstring.len(data[gunnercode].WikiPage)<1thenoutput=data[gunnercode].Rank.."<br />"..data[gunnercode].FirstName.." "..data[gunnercode].Surnameelseoutput=data[gunnercode].Rank.."<br />".."[["..data[gunnercode].WikiPage.."|"..data[gunnercode].FirstName.." "..data[gunnercode].Surname.."]]"endendreturnoutput-- Should never get here, but belts-and -braces... just to be sureendfunctionp.GunnerTable(frame)-- Data Fields-- Code: This is just a duplicate of the lookup code, but expressed as a number instead of a string-- Rank: Person's rank. Not wikilinked--- FirstName: Initials or first name(s)-- Surname: Person's Surname-- Year: Year appointed Master Gunner-- WikiPage: If the person has a Wiki article, name of the article here-- PostNoms: list of Post Nominal Titles. Stored in Lua table format ie Curly braces with values seperated by commas-- Post: The name of the post that they held when awarded. Commas will be turned into line breaks-- Note: Any additional info about this Gunner.-- RecipCat: Category for recipients. "List of Master Gunners (South Africa)"localoutput=''localtemplateArgs=getArgs(frame)locallocalfloat=templateArgs["float"]or''ifnotlocalfloatthenlocalfloat="left"-- NOTE TODO: Make the table float according to the value of locafloat ;-)endlocaltableCode='{| class="wikitable sortable" \n'tableCode=tableCode.."|+ Lys van Meesterkanonieere van die artillerie \n"-- CaptiontableCode=tableCode.."|-\n"tableCode=tableCode.."! Kode !!Nommer !! Rang !! Van !! Voorname !! Pos !! Jaar !! Nota \n"-- Iterate through the data in the table "GunnerData"forcode,recordinpairs(data)do-- Generate wiki table code for the Master Gunner-- TODO: If record.Surname == "Unknown" make the row distinctive somehow.tableCode=tableCode.."|-\n"tableCode=tableCode.."|"..code.."\n"tableCode=tableCode.."| "..record.Code.."\n"tableCode=tableCode.."| "..record.Rank.."\n"ifstring.len(record.WikiPage)<1thentableCode=tableCode.."| "..record.SurnameelsetableCode=tableCode.."| ".."[["..record.WikiPage.."|"..record.Surname.."]]"end-- if string.len(record.Post)>1 then-- tableCode = tableCode .. mw.getCurrentFrame():expandTemplate{ title = 'Efn', args = {"Post occupied when award was made: " .. record.Post} }-- endtableCode=tableCode.."\n"tableCode=tableCode.."| "..record.FirstName.."\n"tableCode=tableCode.."| "..string.gsub(record.Post,","," - <br />").."\n"tableCode=tableCode.."| "..record.Year.."\n"tableCode=tableCode.."| <small>"..record.Note.."</small>\n"endtableCode=tableCode.."|}"-- End the tablereturntableCodeendreturnp-- Initial Code by John Dovey (13 April 2023) [[User:BoonDock]]