Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Random page
Interaction
Help
Community portal
Recent changes
Languages
Language links are at the top of the page across from the title.
Forsaken Saga Wiki
Search
Search
English
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Infobox character/name
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local yesno = require('Module:Yesno') local infobox_image = require('Module:InfoboxImage').InfoboxImage local br = require('Module:Separated entries').br local roman = require('Module:Roman').main local coa = require('Module:Coa/core').main local function split(inputstr, sep) -- This function splits a string by the given separating character sep = sep or '%s' local t = {} for field, s in mw.ustring.gmatch(inputstr, "([^" .. sep .. "]*)(" .. sep .. "?)") do table.insert(t, field) if s == "" then return t end end end local function is_empty(s) -- This function checks whether a string is empty return s == nil or s == '' end local function overspecified_arms(arms) arms = mw.ustring.lower(arms) local patterns = { "^%[%[file:", "%|.*%]%]$", "^house ", "^coin of", "%.png$", "%.svg$", "%.jpe?g$", "^none", } for _, pattern in pairs(patterns) do if mw.ustring.find(arms, pattern) then return "[[Category:Character pages with overspecified arms]]" end end return "" end local function generate_arms(arms, size) --This function generates small coat of arms icons return coa{ arms, format = 'image', size = size or 'infobox-l', } .. overspecified_arms(arms) end local p = {} function p.main(frame) local MAX_ARMS = 5 local args = getArgs(frame) args.arms1 = args.arms1 or args.arms local template = args.nametemplate or nil local regnalnumber = args.regnalnumber or "" local lastfirst = yesno(args.lastfirst) -- whether last name comes before first name local name_parts = {} name_parts.fullname = args.name or args.fullname or "" name_parts.title = args.title or "" name_parts.nickname = args.nickname or "" name_parts.firstname = args.firstname or "" name_parts.particle = args.particle or "" name_parts.lastname = args.lastname or "" name_parts.epithet = args.epithet or "" name_parts.romanregnalnumber = roman({ regnalnumber }) or "" local categories = {"Character pages with new syntax name"} if is_empty(template) then if not is_empty(name_parts.firstname) then if not is_empty(name_parts.lastname) then if lastfirst then template = 'title/nickname-lastname-particle-firstname-romanregnalnumber/epithet' else template = 'title/nickname-firstname-romanregnalnumber-particle-lastname/epithet' end else template = 'title/nickname-firstname-epithet/' end elseif not is_empty(name_parts.lastname) then template = '/nickname-title-particle-lastname/epithet' elseif not is_empty(name_parts.nickname) then template = '/title-nickname/epithet' elseif not is_empty(name_parts.title) then template = '/title/epithet' elseif not is_empty(name_parts.epithet) then template = '/epithet/' elseif not is_empty(name_parts.fullname) then error("The name parameter is deprecated and can no longer be used") end else table.insert(categories, "Character pages with custom nametemplate") end -- Parse name template to get the above, core, and below texts local above_template, core_template, below_template = unpack(split(template, '/')) local above = '' for _, part in pairs(split(above_template, '-')) do if not is_empty(name_parts[part]) then above = above .. ' ' .. name_parts[part] end end local core = '' for _, part in pairs(split(core_template, '-')) do if not is_empty(name_parts[part]) then core = core .. ' ' .. name_parts[part] end end local below = '' for _, part in pairs(split(below_template, '-')) do if not is_empty(name_parts[part]) then below = below .. ' ' .. name_parts[part] end end -- Build above and below texts and full name local above_span = "" if not is_empty(above) then above_span = mw.html.create('span') above_span:css('font-size', '80%') :css('font-weight', 'normal') :wikitext(above) end local below_span = "" if not is_empty(below) then below_span = mw.html.create('span') below_span:css('font-size', '80%') :css('font-weight', 'normal') :wikitext(below) end local name = br({ tostring(above_span), core, tostring(below_span), }) local complete_name -- The module looks different based on the number of arms to display if args.arms1 and args.arms2 and args.arms3 then -- Three or more arms complete_name = mw.html.create('div') complete_name:css('text-align', 'justify') :css('text-justify', 'distribute-all-lines') local coasize if is_empty(args.arms4) then coasize = 'infobox-m' table.insert(categories, "Character pages with 3 coats of arms") else coasize = 'infobox-s' table.insert(categories, "Character pages with 4+ coats of arms") end for i=1,MAX_ARMS do local arms = args['arms' .. tostring(i)] if arms then complete_name:wikitext(generate_arms(arms, coasize)) :wikitext(" ") end end complete_name:tag('span') :css('display', 'inline-block') :css('width', '100%') :css('text-align', 'center') :wikitext(name) elseif args.arms1 then -- One or two arms local arms1 = args.arms1 local arms2 if is_empty(args.arms2) then arms2 = args.arms1 table.insert(categories, "Character pages with 1 coat of arms") else arms2 = args.arms2 table.insert(categories, "Character pages with 2 coats of arms") end complete_name = mw.html.create('table') complete_name:css('width', '100%') :tag('tr') :tag('td'):css('border', 'none') :css('vertical-align', 'top') :css('text-align', 'left') :css('width', '50px') :wikitext(generate_arms(arms1)) :done() :tag('td'):css('border', 'none') :css('vertical-align', 'middle') :css('text-align', 'center') :css('padding', '0px 7px 5px 7px') :wikitext(name) :done() :tag('td'):css('border', 'none') :css('vertical-align', 'top') :css('text-align', 'right') :css('width', '50px') :wikitext(generate_arms(arms2)) else -- No arms complete_name = name if categories[1] == "Character pages with new syntax name" then table.insert(categories, "Character pages with 0 coats of arms") end end -- Add all categories complete_name = tostring(complete_name) for _, category in pairs(categories) do complete_name = complete_name .. "[[Category:" .. category .. "]]" end return complete_name end return p
Summary:
Please note that all contributions to Forsaken Saga Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Infobox character/name/doc
(
edit
)
Toggle limited content width