模块:测试调用数据:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local | -- 加载数据 | ||
local | local db_cn = mw.loadData('模块:角色技能数据中文') | ||
local | local db_jp = mw.loadData('模块:角色技能数据日文') | ||
local query_lang = frame.args['查询语言'] | |||
if query_lang == "cn" then | |||
dataList = db_cn.char_skill_data | |||
else | |||
dataList = db_jp.char_skill_data | |||
end | |||
p["测试调用"] = function(frame) | p["测试调用"] = function(frame) | ||
local query_num = frame.args[' | local query_num = frame.args['角色序号'] | ||
local query_type = frame.args['查询类型'] | |||
local html = mw.html.create() | local html = mw.html.create() | ||
for _, skillList in ipairs(dataList) do | |||
if query_num == skillList.owner_order then | |||
for _, skill in ipairs(skillList.owner_skill) do | |||
if skill.skill_parent ~= nil and query_type == skill.skill_type then | |||
html:tag('div'):wikitext(skill.skill_name .. skill.skill_content) | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
return tostring(html) | return tostring(html) | ||
end | end | ||
return p | return p |
2024年6月28日 (五) 16:13的版本
可在模块:测试调用数据/doc创建此模块的帮助文档
local p = {}
-- 加载数据
local db_cn = mw.loadData('模块:角色技能数据中文')
local db_jp = mw.loadData('模块:角色技能数据日文')
local query_lang = frame.args['查询语言']
if query_lang == "cn" then
dataList = db_cn.char_skill_data
else
dataList = db_jp.char_skill_data
end
p["测试调用"] = function(frame)
local query_num = frame.args['角色序号']
local query_type = frame.args['查询类型']
local html = mw.html.create()
for _, skillList in ipairs(dataList) do
if query_num == skillList.owner_order then
for _, skill in ipairs(skillList.owner_skill) do
if skill.skill_parent ~= nil and query_type == skill.skill_type then
html:tag('div'):wikitext(skill.skill_name .. skill.skill_content)
end
end
end
end
return tostring(html)
end
return p