Module:Characters

From Umamusume Wiki
Revision as of 03:20, 2 March 2024 by Snep (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Characters/doc

local p = {}
local cargo = mw.ext.cargo

function p.list(frame)
	local query = {
		limit = '1000',
		orderBy = 'Characters.name_en ASC',
	}
	local fields = 'name_en,image,_pageName'
	local characters = cargo.query('Characters', fields, query)
	
	local root = mw.html.create('div'):cssText('display:flex; flex-flow:row wrap;')
	for _, ch in ipairs(characters) do
		local anchor = mw.html.create('a'):attr('href', '/' .. ch._pageName)
		local template = frame:expandTemplate{
			title='Character Icon',
			args={
				icon=ch.image,
				name_en=ch.name_en,
				color_main='fac',
				color_sub='caf',
				link=ch._pageName
			}
		}
		anchor:wikitext(template)
		root:node(anchor)
	end
	return root
end

return p