模块:测试调用数据
可在模块:测试调用数据/doc创建此模块的帮助文档
local p = {}
local db = mw.loadData('模块:角色属性数据')
local dataList = db.char_self_data
local elements = {"HP", "SP", "ATK", "DEF", "MAG", "MDEF", "CRT", "SPD"}
p["测试调用"] = function(frame)
local query_num = frame.args['角色编号']
local result = {} -- 结果表,用于存储输出的结果
for _, char in ipairs(dataList) do
if query_num == char.owner_order then
for _, element in ipairs(elements) do
local maxAttr = "MAX" .. element
local maxAttrValue = char.Data_jp[maxAttr]
testTable(result, maxAttr, maxAttrValue)
local baseAttr = "Base" .. element
local baseAttrValue = char.Data_jp[baseAttr]
testTable(result, baseAttr, baseAttrValue)
end
end
end
return table.concat(result, "<br>") -- 将结果表连接为一个字符串,以换行符分隔
end
function testTable(resultTable, a, b)
table.insert(resultTable, a .. ":".. b)
end
return p