模块:测试调用数据:修订间差异
无编辑摘要 |
无编辑摘要 |
||
第5行: | 第5行: | ||
local db_jp = mw.loadData('模块:角色技能数据日文') | local db_jp = mw.loadData('模块:角色技能数据日文') | ||
local dataList_jp = db_jp.char_skill_data | local dataList_jp = db_jp.char_skill_data | ||
local function split(input, delimiter) | |||
local result = {} | |||
for match in (input .. delimiter):gmatch("(.-)" .. delimiter) do | |||
table.insert(result, match) | |||
end | |||
return result | |||
end | |||
local function skillBox(skill) | local function skillBox(skill) | ||
第10行: | 第18行: | ||
skillBoxDiv = skillBoxDiv:tag('div'):wikitext(skill.skill_name) | skillBoxDiv = skillBoxDiv:tag('div'):wikitext(skill.skill_name) | ||
:tag('div'):wikitext(skill.skill_tag) | :tag('div'):wikitext(skill.skill_tag) | ||
:tag('div'):wikitext(string.format(' | :tag('div'):wikitext(string.format('{{特性图标|%s}}', skill.skill_tag)) | ||
return skillBoxDiv | return skillBoxDiv | ||
end | end |
2024年6月29日 (六) 06:48的版本
可在模块:测试调用数据/doc创建此模块的帮助文档
local p = {}
-- 加载数据
local db_cn = mw.loadData('模块:角色技能数据中文')
local dataList_cn = db_cn.char_skill_data
local db_jp = mw.loadData('模块:角色技能数据日文')
local dataList_jp = db_jp.char_skill_data
local function split(input, delimiter)
local result = {}
for match in (input .. delimiter):gmatch("(.-)" .. delimiter) do
table.insert(result, match)
end
return result
end
local function skillBox(skill)
local skillBoxDiv = mw.html.create()
skillBoxDiv = skillBoxDiv:tag('div'):wikitext(skill.skill_name)
:tag('div'):wikitext(skill.skill_tag)
:tag('div'):wikitext(string.format('{{特性图标|%s}}', skill.skill_tag))
return skillBoxDiv
end
p["测试调用"] = function(frame)
local query_num = frame.args['角色序号']
local query_type = frame.args['查询类型']
local query_lang = frame.args['查询语言'] or ""
local html = mw.html.create()
-- 提取数据
local dataList = (query_lang == "cn" or query_lang == "国服") and dataList_cn or dataList_jp
for _, ownerList in ipairs(dataList) do
if query_num == ownerList.owner_order then
-- 上面没问题
for _, skill in ipairs(ownerList.owner_skill) do
if skill.skill_type == query_type and skill.skill_parent == nil then
html:node(skillBox(skill))
end
end
end
end
return tostring(html)
end
return p