模块:CharacterInfo
来自异世界百科
此模块的文档可以在模块:CharacterInfo/doc创建
local p = {}
function p.create(frame)
-- 信息项
local name = frame.args.name
local originalName = frame.args.original_name
local age = frame.args.age
local gender = frame.args.gender or frame.args.custom_gender
-- 配置项
local picture = frame.args.picture
local displayType = frame.args.display_type
local float = frame.args.float
local content = frame.args.content or ""
local dataAge = age
-- 年龄不是数字,则不进入数据表
if not dataAge:match("^%-?%d+$") then
dataAge = nil
end
local dataTable = {}
local infoTable = {
["title_key"] = "名字"
}
if name then
infoTable["名字"] = name
dataTable["name"] = name
end
-- 原语言名字显示为上标
if originalName then
infoTable["名字"] = "{{上标|" .. name .. "|" .. originalName .. "}}"
dataTable["original_name"] = originalName
end
if gender then
infoTable["性别"] = gender
dataTable["gender"] = gender
end
if age then
infoTable["年龄"] = age
end
if dataAge then
dataTable["age"] = dataAge
end
if picture then
infoTable["picture"] = picture
dataTable["picture"] = picture
end
if displayType then
infoTable["type"] = displayType
else
infoTable["type"] = "hidden"
end
if float then
infoTable["float"] = float
end
local finalHtml = frame:expandTemplate{ title = "信息/角色", args = dataTable }
-- 自动生成内容
if displayType ~= "hidden" then
finalHtml = finalHtml .. frame:extensionTag("information", content, infoTable)
end
return finalHtml
end
return p