Module:Characters: Difference between revisions

From Umamusume Wiki
Jump to navigation Jump to search
(Created page with "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 template = frame:expandTemplate{ title='Character Icon', args={ icon=ch.image, name_en=ch.n...")
 
mNo edit summary
 
(13 intermediate revisions by the same user not shown)
Line 7: Line 7:
orderBy = 'Characters.name_en ASC',
orderBy = 'Characters.name_en ASC',
}
}
local fields = 'name_en,image,_pageName'
if frame.args[1] == 'horsegirls' then
local characters = cargo.query('Characters', fields, query)
query.where = 'Characters.type="horsegirl" AND Characters.media IS NULL'
elseif frame.args[1] == 'other' then
query.where = 'NOT Characters.type="horsegirl" AND Characters.media IS NULL'
elseif frame.args[1] == 'cinderellagray' then
query.where = 'Characters.media="cinderellagray"'
elseif frame.args[1] == 'starblossom' then
query.where = 'Characters.media="starblossom"'
elseif frame.args[1] == 'anime' then
query.where = 'Characters.media="anime"'
end
local fields = {'_pageName','name_en','icon','color_main','color_sub'}
local characters = cargo.query('Characters',
table.concat(fields, ','), query)
local root = mw.html.create('div'):cssText('display:flex; flex-flow:row wrap;')
local root = mw.html.create('div'):cssText('display:flex; flex-flow:row wrap; gap: 10px;')
for _, ch in ipairs(characters) do
for _, ch in ipairs(characters) do
local template = frame:expandTemplate{
if ch.icon then
title='Character Icon',
local template = frame:expandTemplate{
args={
title='Character Icon',
icon=ch.image,
args={
name_en=ch.name_en,
icon=ch.icon,
color_main='fac',
name_en=ch.name_en,
color_sub='caf',
color_main=ch.color_main,
link=ch._pageName
color_sub=ch.color_sub,
link=ch._pageName
}
}
}
}
root:wikitext(mw.text.trim(template))
root:wikitext(template)
end
end
end
return root
return root
end
function p.profile(frame)
local charName = frame.args[1]
if not charName then return end
local query = {
limit = '1',
where = 'name_en="' .. charName .. '"',
}
local fields = {'strengths','weaknesses','ears','tail','family',
'my_rule','phone_background','before_a_race','good_subject',
'secret_pride','frequent_purchase','secret1','secret2'}
local characters = cargo.query('Characters',
table.concat(fields, ','), query)
local ch = characters[1]
if not ch then return end
local template = frame:expandTemplate{
title='Character Profile/table',
args={
strengths=ch.strengths,
weaknesses=ch.weaknesses,
ears=ch.ears,
tail=ch.tail,
family=ch.family,
my_rule=ch.my_rule,
phone_background=ch.phone_background,
before_a_race=ch.before_a_race,
good_subject=ch.good_subject,
secret_pride=ch.secret_pride,
frequent_purchase=ch.frequent_purchase,
secret1=ch.secret1,
secret2=ch.secret2,
}
}
return template
end
end


return p
return p

Latest revision as of 21:28, 15 April 2024

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',
	}
	if frame.args[1] == 'horsegirls' then
		query.where = 'Characters.type="horsegirl" AND Characters.media IS NULL'
	elseif frame.args[1] == 'other' then
		query.where = 'NOT Characters.type="horsegirl" AND Characters.media IS NULL'
	elseif frame.args[1] == 'cinderellagray' then
		query.where = 'Characters.media="cinderellagray"'
	elseif frame.args[1] == 'starblossom' then
		query.where = 'Characters.media="starblossom"'
	elseif frame.args[1] == 'anime' then
		query.where = 'Characters.media="anime"'
	end
	local fields = {'_pageName','name_en','icon','color_main','color_sub'}
	local characters = cargo.query('Characters',
		table.concat(fields, ','), query)
	
	local root = mw.html.create('div'):cssText('display:flex; flex-flow:row wrap; gap: 10px;')
	for _, ch in ipairs(characters) do
		if ch.icon then
			local template = frame:expandTemplate{
				title='Character Icon',
				args={
					icon=ch.icon,
					name_en=ch.name_en,
					color_main=ch.color_main,
					color_sub=ch.color_sub,
					link=ch._pageName
				}
			}
			root:wikitext(mw.text.trim(template))
		end
	end
	return root
end

function p.profile(frame)
	local charName = frame.args[1]
	if not charName then return end
	local query = {
		limit = '1',
		where = 'name_en="' .. charName .. '"',
	}
	local fields = {'strengths','weaknesses','ears','tail','family',
		'my_rule','phone_background','before_a_race','good_subject',
		'secret_pride','frequent_purchase','secret1','secret2'}
	local characters = cargo.query('Characters',
		table.concat(fields, ','), query)

	local ch = characters[1]
	if not ch then return end
	local template = frame:expandTemplate{
		title='Character Profile/table',
		args={
			strengths=ch.strengths,
			weaknesses=ch.weaknesses,
			ears=ch.ears,
			tail=ch.tail,
			family=ch.family,
			my_rule=ch.my_rule,
			phone_background=ch.phone_background,
			before_a_race=ch.before_a_race,
			good_subject=ch.good_subject,
			secret_pride=ch.secret_pride,
			frequent_purchase=ch.frequent_purchase,
			secret1=ch.secret1,
			secret2=ch.secret2,
		}
	}
	return template
end

return p