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:Coa/core
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 data = mw.loadData('Module:Coa/data') local p = {} local function find_key(key) key = mw.ustring.lower(key) -- make lowercase local patterns = { -- "^%[%[file:", -- "%|.*%]%]$", -- "^house ", -- "^coin of", -- "%.png$", -- "%.svg$", -- "%.jpe?g$", } for _, pattern in pairs(patterns) do -- remove some words key = mw.ustring.gsub(key, pattern, "") end local patterns2 = { " of ", " the ", } for _, pattern in pairs(patterns2) do -- remove some words, replace with space key = mw.ustring.gsub(key, pattern, " ") end key = mw.ustring.gsub(key, "[^a-z0-9]", "") -- remove all non-alphanumeric characters return key end local function get(key) local house = data[find_key(key)] if house == nil then error('"' .. key .. '" is not a valid COA') else return house end end local function coa(file, link, text, size, format) if format == 'file' then return file elseif format == 'image' then return '[[File:' .. file .. '|' .. size .. '|link=' .. link .. ']]' elseif format == 'text' then if link == nil or text == nil then return '[[File:' .. file .. '|' .. size .. '|link=]]' else return '[[File:' .. file .. '|' .. size .. '|link=' .. link .. ']] [[' .. link .. '|' .. text .. ']]' end end end local function get_size(size) local sizes = { xs = '16x18px', s = '20x22px', m = '32x35px', l = '100x110px', xl = '250x275px', ['infobox-l'] = '50x55px', ['infobox-m'] = '40x44px', ['infobox-s'] = '32x35px', } return sizes[size] or sizes['xs'] end function p.main(frame) local args = getArgs(frame) local key = args[1] if key == nil then error("No key given") end local house = get(key) local file = args['file'] or house['file'] or "None.svg" local link = args['link'] or house['page'] or "" local text = args['text'] or house['name'] or house['page'] local size = get_size(args['size'] or args[2]) local format = args['format'] local coa_ = coa(file, link, text, size, format) if mw.ustring.find(find_key(key), "^none") then return "[[Category:Explicitly unknown coat of arms]]" .. coa_ elseif mw.ustring.find(find_key(key), "^unknown") then return "[[Category:Explicitly unknown coat of arms]]" .. coa_ else return coa_ end end function p.list(frame) local t = '{| class="wikitable"' for key, house in pairs(data) do t = t .. '\n|-\n| <code>' .. key .. '</code> || ' .. coa( house['file'] or "None.svg", house['page'], house['name'] or house['page'], '16x18px', 'text' ) end t = t .. '\n|}' return t end function p.png_list(frame) local t = '{| class="wikitable"' for key, house in pairs(data) do local file = house['file'] or "None.svg" if mw.ustring.match(file, "%.svg$") == nil then t = t .. '\n|-\n| <code>' .. key .. '</code> || ' .. coa( file, ":File:" .. file, file, '100x110px', 'text' ) end end t = t .. '\n|}' return t 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:Coa/core/doc
(
edit
)
Toggle limited content width