此处为全站公告,通常对读者进行申明或对该WIKI某些规则进行公告,请在确认后修改本通告。本WIKI编辑权限开放,欢迎收藏起来防止迷路,也希望有爱的小伙伴和我们一起编辑哟~

全站通知:

模块:Test 7709386

来自星塔旅人WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:Test 7709386/doc创建

local p = {}

local function _load_json(page_title)
	if page_title ~= nil then
		return mw.text.jsonDecode(mw.title.new(page_title):getContent())
	end
end

function p.test(frame)
	local args = frame.args or {}
    local nCharId, sKey = args[1] and tonumber(args[1]) or nil, args[2] or nil
    local tbAllCharData = _load_json("用户:7709386/Data:Test.json")
    -- key = prfer_list or hate_list
    if nCharId ~= nil and sKey ~= nil and tbAllCharData and tbAllCharData[nCharId] then
		local tbCurCharData = tbAllCharData[nCharId]
		local tbCurCharPreferenceData = tbCurCharData["preference_data"]
		if tbCurCharPreferenceData and tbCurCharPreferenceData[sKey] then
			local data = tbCurCharPreferenceData[sKey]
			local result = {}
    		for i =1,#data do
    			table.insert(result, data[i]["name"])
    		end
    		return table.concat(result,",")
		end
    end
    return ""
end

return p