WIKI公告栏
欢迎各位引航者访问卡拉彼丘WIKI,由于游客访问页面会有一定的页面旧版缓存,建议你登陆B站账号进行浏览,如果您觉得本WIKI有帮助到你,欢迎推荐给身边的引航者。
全站通知:

模块:角色表情

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

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

local p = {}

local data = mw.text.jsonDecode(mw.title.new('模块:角色表情/Data.json'):getContent() or '{}')

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

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

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

    for key, rolename in pairs(data) do
        if emoterole == rolename['Role'] then
            local emotehtml = rolename['File'] .. "|'''" .. splitKey(key) .. "'''<br>" .. rolename['Desc_string']
            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 = {}

  local function splitKey(key)
        local parts = {}
        for part in key:gmatch("[^-]+") do
            table.insert(parts, part)
        end
        return parts[2]
  end
    
  for key, rolename in pairs(data) do
        if emoterole == rolename['Role'] then
            local emotehtml = rolename['File'] .. "|'''" .. splitKey(key) .. "'''<br>" .. rolename['Desc_string']
            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 = {}

  local function splitKey(key)
        local parts = {}
        for part in key:gmatch("[^-]+") do
            table.insert(parts, part)
        end
        return parts[2]
  end
    
  for key, emoteData in pairs(data) do
    if string.find(emoteData['Get'],emoterole, 1, true) then
      local emotehtml = emoteData['File'] .. "|'''<big>" .. emoteData['Role'] .. "表情:" .. splitKey(key) .. "</big>'''<br>" 
      .. frame:expandTemplate{ title = '稀有度标签', args = { emoteData['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