Module:PC

local p = { argDefs={ loadName={isNumeric=false, path={}, doc='Name of the player module from which data should be loaded'}, name={isNumeric=false, path={'shortName'}, doc='Display name of the character.'}, user={isNumeric=false, path={'user'}, doc='Username of the player'}, race={isNumeric=false, path={'race'}, doc='Race of the character'}, gender={isNumeric=false, path={'gender'}, doc='Gender of the character'}, age={isNumeric=false, path={'age'}, doc='Age of the character'}, role={isNumeric=false, path={'role'}, doc='Quick description of what the character does'}, firstExpedition={isNumeric=false, path={'firstExpedition'}, doc='Where the character made their first expedition'}, expeditionsSurvived={isNumeric=false, path={'expeditionsSurvived'}, doc='How many expeditions the character has survived'}, reasonForJoining={isNumeric=false, path={'reasonForJoining'}, doc='Why the character joined our merry band of adventurers'}, goal={isNumeric=false, path={'shortGoal'}, doc='What is the character\'s goal in life (should usually relate to why they joined, unless they were abducted)'}, status={isNumeric=false, path={'characterStatus'}, doc='Usually one of three states (Alive, Dead, Inactive) though other states may occur (e.g. a character might leave the bore because they achieved their goal)'}, image={isNumeric=false, path={'image'}, doc='The name of an image file in the forum that will be displayed at the top of the PC template (e.g. Crow.jpg)'}, imagewidth={isNumeric=false, path={'imagewidth'}, doc='How wide the image should be when displayed. Use reasonable values. Around 200px should be fine. Defaults to 210px.'}, imagecaption={isNumeric=false, path={'imagecaption'}, doc='A small text to be displayed on image mousover and under the image'}, } }

local utils = require('Module:Utils') function p.addRow(htmltable, rowTitle, inRowText) local rowText = 'Unknown' if (inRowText ~= nil) then rowText = inRowText end htmltable :tag('tr') :css('color', 'white') :css('background', '#313e55') :tag('th') :css('text-align', 'right') :css('vertical-align', 'top') :css('font-size', '110%') :css('width', '40%') :wikitext(rowTitle) :done :tag('td') :css('text-align', 'left') :css('vertical-align', 'top') :css('font-size', '100%') :wikitext(rowText) end function p.createtableInternal(args) -- Create an empty string that will be returned at the end of the function -- New things will be added to the string as we do them local retString = "" -- Create an html node that will represent the table local htmltable = mw.html.create('table') -- Change that node's css properties so that it has the proper style htmltable :css('width','100%') :css('font-size', '80%') :css('float', 'right') :css('margin', '0 0 0em 0em') :css('border-style', 'solid') :css('border-width', '3px') :css('border-color', 'rgb(204, 153, 102)') :css('background', '#313e55') :css('padding', '1px 1px') :css('color', 'white') :css('text-align', 'left') :attr('cellpadding', '1') :attr('cellspacing', '1') -- Add player name local name = 'Unknown' if(args.name ~= nil) then name = args.name; end htmltable:tag('tr') :css('background', '#313e55') :tag('th') :attr('colspan', 2) :css('text-align', 'center') :css('font-size','130%') :wikitext(name) -- Add image if it exists if(args.image ~= nil) then local imagewidth = '210px' if(args.imagewidth ~= nil) then imagewidth = args.imagewidth end local imagecaption = '' if(args.imagecaption ~= nil) then imagecaption = args.imagecaption end htmltable:tag('tr') :css('background', '#313e55') :tag('td') :addClass('wikia-infobox-image') :attr('colspan', 2) :css('text-align', 'center') :wikitext('') if(args.imagecaption ~= nil) then htmltable:tag('tr') :css('background', '#313e55') :tag('td') :attr('colspan', 2) :css('text-align', 'center') :css('font-style', 'italic') :css('font-size', '80%') :wikitext(imagecaption) end end -- Add info rows p.addRow(htmltable, 'User', args.user) p.addRow(htmltable, 'Race', args.race) p.addRow(htmltable, 'Gender', args.gender) p.addRow(htmltable, 'Age', args.age) p.addRow(htmltable, 'Role', args.role) p.addRow(htmltable, 'First Expedition', args.firstExpedition) p.addRow(htmltable, 'Expeditions Survived', args.expeditionsSurvived) p.addRow(htmltable, 'Reason for joining', args.reasonForJoining) p.addRow(htmltable, 'Goal', args.goal) p.addRow(htmltable, 'Status', args.status) -- Add the table to the retString retString = retString .. tostring(htmltable) --local debugDiv = mw.html.create('div') --debugDiv:css('color','transparent') --       :css('display','none') --       :wikitext(mw.text.nowiki(retString)) --retString = retString .. tostring(debugDiv) if(args.status ~= nil) then local lowerStatus = string.lower(args.status) local charCategoryString = 'Character' if (string.match(lowerStatus, 'npc')) then charCategoryString = 'Non-Player Character' elseif (lowerStatus == 'alive') then charCategoryString = 'Active Character' elseif (lowerStatus == 'dead') then charCategoryString = 'Dead Character' elseif (lowerStatus == 'inactive') then charCategoryString = 'Inactive Character' end retString = retString .. ""   end -- Return the retString return retString end

--use loadName argument to load data from DB, all other arguments override loaded args function p.createtable(frame) local args = {} --Load args from DB	args = utils.argsFromPlayer(frame.args.loadName, args, p.argDefs) --Override DB args from frame args args = utils.argsFromFrame(frame, args, p.argDefs) --Remember to preprocess everything before returning the string return frame:preprocess(p.createtableInternal(args)) end return p