全站通知:
模块:提取灵空道具数据
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:提取灵空道具数据/doc创建
local p = {}
function p.getData()
local jsonText = mw.title.new("data:Unicorns/Items.json"):getContent()
if not jsonText then
return "找不到json文件内容"
end
-- 解析 json 内容
local data = mw.text.jsonDecode(jsonText)
if not data then
return "无法解析json内容"
end
return data
end
-- 用于在模板中调用
function p.show(frame)
local data = p.getData()
if type(data) ~= "table" then
return data
end
local root = mw.html.create()
for _, code in ipairs(data) do
local args = {
["名称"] = code["名字"],
["显示名称"] = code["名字"],
["显示图片"] = code["名字"],
["角色"] = code["角色"],
["功能描述"] = code["描述1"],
["背景描述"] = code["描述2"],
["获取途径"] = "灵空行动",
}
local html = frame:expandTemplate{ title = "灵空道具/个", args = args }
root:wikitext(html)
end
return tostring(root)
end
return p