bugfix20250107.1
全站通知:

模块:角色表情

来自卡拉彼丘WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:角色表情/doc创建

local p = {}

local data = mw.loadData("模块:角色表情/Data")

------获取调用页面名
local function getPageTitle()
	return mw.title.getCurrentTitle().text
end


local function splitKey(key)
	local parts = {}
	for part in key:gmatch("[^-]+") do
		table.insert(parts, part)
	end
	return parts[2]
end

------角色页角色表情
p["角色表情"] = function (frame)
	local emoteRole = getPageTitle()
	local resultList = {}

	for _, emote in pairs(data) do
		if emoteRole == emote.role then
			local emoteHTML = emote.file.."|'''<big>"..splitKey(emote.name)
				.."</big>'''<br><small>"..emote.desc.."</small><br>获得方式:"..emote.get
			table.insert(resultList, tostring(emoteHTML))
		end
	end

	local result = table.concat(resultList, "\n")
	return result..'\n'
end


------表情包页面
p["表情包"] = function (frame)
	local emoteRole = frame.args[1]
	local resultList = {}

	for _, emote in pairs(data) do
		if emoteRole == emote.role then
			local emoteName = ""
			if emote.role == "其它" then
				emoteName = emote.name
			else
				emoteName = splitKey(emote.name)
			end
			local emoteHTML = emote.file.."|'''<big>"..emoteName
				.."</big>'''<br><small>"..emote.desc.."</small><br>获得方式:"..emote.get
			table.insert(resultList, tostring(emoteHTML))
		end
	end

	local result = table.concat(resultList, "\n")
	return frame:preprocess('<gallery mode="packed">\n'..result..'\n</gallery>')
end


------意识重构页角色表情
p["意识重构角色表情"] = function (frame)
	local emoteRole = frame.args[1]
	local resultList = {}

	for _, emote in pairs(data) do
		if string.find(emote.get, emoteRole, 1, true) then
			local emoteHTML = emote.file..
				"|'''<big>"..emote.role.."表情:"..splitKey(emote.name).."</big>'''"
				..frame:expandTemplate { title = '稀有度标签', args = { emote.quality } }
			table.insert(resultList, tostring(emoteHTML))
		end
	end

	local result = table.concat(resultList, "\n")
	return frame:preprocess('<gallery mode="packed">\n'..result..'\n</gallery>')
end

return p