Module:CharImage

local cargo = require('Module:CargoUtil') local util_table = require('Module:TableUtil') local quote = function(s) return ("%q"):format(s) end

local p = {}

function p.main(frame) local args = require('Module:Arguments').getArgs(frame) local lines = mw.text.split(mw.text.trim(args[2]), '\n') local data = {} for i, line in ipairs(lines) do		local columns = mw.text.split(line, ';') local key = columns[1] data[key] = { name = columns[1], isCharacter = columns[2] == '.', portraits = {}, }		for j=3,#columns do			local s = columns[j] table.insert(data[key].portraits, s)		end end local keys = util_table.getKeys(data) local names = util_table.concat(keys, ',', quote) local rows = cargo.query{ tables = '_pageData, Pages, Unit, UnitLoc', join = { '_pageData._pageName = Pages._pageName', 'Pages.iname = Unit.iname', 'Unit.iname = UnitLoc.iname', },		fields = { '_pageData._pageName=PAGENAME', 'Pages.iname=iname', 'Unit.img=img', 'UnitLoc.name=name', },		where = { '_pageData._pageName IN ('..names..')', 'COALESCE(Unit.server,"gl") = "gl"', 'COALESCE(UnitLoc.lang,"english") = "english"', },	}	local root = { '=== '..args[1]..' ===', '{| width="100%" style="background: #F1F1F1; color: #34515E; font-size: 16px; font-family: Ebrima, Verdana, sans-serif" cellspacing="0" cellpadding="2"', '|- align="center" valign="center"', '! width="16%" style="background: #F7F7F7; font-size:16px; padding: 10px; border-bottom: 2px solid silver" |Character', '! width="84%" colspan="6" style="background: #F7F7F7; font-size:16px; padding: 10px; border-bottom: 2px solid silver" |Images', }

for _, row in ipairs(rows) do		local key = row.PAGENAME local icon = row.img and ' '..row.name.. or  table.insert(root, '|- align="center"') table.insert(root, '! valign="center" style="font-size:18px; padding: 10px; border-bottom: 1px solid silver" | '..key) table.insert(root, '| valign="top" width="16%" style="background: #F7F7F7; padding: 10px; border-bottom: 1px solid silver" | '..icon) local portraits = data[key].portraits for _, s in ipairs(portraits) do			local img = '' if s ~= '' then img = ' '..s			end table.insert(root, '| valign="top" width="16%" style="padding: 10px; border-bottom: 1px solid silver" | '..img) end end table.insert(root, '|}') return table.concat(root, '\n') end

function p.test local names = Acht;.;Acht (Eye);;;; Adaleigh;.;Adaleigh (NPC);;;; Adel;;Adel;;;; Adelbert;;Adelbert;;;; Adone;;Adone;;;; Agatha;;Agatha;Agatha2;;; Ainanna;.;Ainanna (NPC);Ephylinde;;; Aisha;.;Aisha (NPC);Aisha (Swimsuit);;; AJ10;;AJ10;;;; Alaia;.;Alaia (NPC);;;; Albea;.;Albea (NPC);Albea (Memento NPC);Albea (Valentine NPC);; Alexis;.;Alexis (Halloween NPC);;;; Alfred;.;Alfred (NPC);;;; Alkemono;;Alkemono;Alkemono (Cap);;; Alma;.;Alma (NPC);Alma (Swimsuit);;; Almace;.;;;;; Almira;.;Almira (NPC);Almira (Swimsuit NPC);;; Alvarez;;Alvarez;Messiah;;; Alyu;.;Alyu (NPC);;;; Amane;.;Amane (Past);;;; Amaterasu;.;Amaterasu (Swimsuit NPC);;;; Ambrosia;.;;;;; Amis;.;Amis (NPC);;;; Anastasia;.;;;;; Andechs;;Andechs (NPC);;;; Ankh;.;Ankh (White Day NPC);;;; Anna;;Anna;;;; Annerose;.;Annerose (NPC);;;; Annika;.;Annika (NPC);;;; Anwyn;;Eira's Fox;Eira's Fox (Winter Surprise);;; Arius;;Arius;Arius0;;; Arkil;.;Arkil (NPC);;;; Aruba;.;Aruba (NPC);;;; Asena;;Asena;Asena (Shadow);Asena1;Asena's Shadow; Asmodeus;;Asmodeus;;;; Asuka;.;;;;; Aswald;.;Aswald (NPC);Aswald (Wedding);;; Atropos;;Atropos;;;; Azami;;Azami (NPC);Azami (Past NPC);;; return p.main{'A', names} end

return p