全站通知:
模块:角色语音
刷
历
编
跳到导航
跳到搜索
数据库 模块:角色语音/voice数据库 模块:角色语音/voice.json
模块 模块:角色语音
local p = {}
-- 加载数据模块(安全模式)
local success, data = pcall(mw.loadData, '模块:角色语音/voice')
if not success then
mw.log("模块:角色语音/voice 加载失败:", data)
return { main = function() return "" end }
end
-- 主函数
function p.main(frame)
local category = tostring(frame.args[1] or "")
local key = tostring(frame.args[2] or "")
local separator = tostring(frame.args[3] or ", ") -- 默认用逗号分隔,支持自定义(如 "<br>")
-- 检查数据有效性
if not data[category] then
mw.log("分类不存在:", category)
return ""
end
local result = data[category][key]
-- 处理结果
if not result then
return ""
elseif type(result) == "table" then
-- 安全转换表为字符串(避免元表干扰)
local items = {}
for i, v in ipairs(result) do
items[i] = tostring(v)
end
return table.concat(items, separator) -- 支持自定义分隔符
else
return tostring(result)
end
end
return p

沪公网安备 31011002002714 号