Module:沙盒/盐棋/Sandbox1:修订间差异
小 (调试传入参数) |
小 (Nintendo Switch beyond filter) |
||
第24行: | 第24行: | ||
end | end | ||
end | end | ||
end | |||
function NSBydFilter(info) | |||
local NsBydList={["tempestissimo"] = true} | |||
if info["difficulties"][4] and not NsBydList[info["id"]] then | |||
info["difficulties"][4] = nil | |||
end | |||
return info | |||
end | end | ||
function p.GetSong(args) | function p.GetSong(args) | ||
local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id']) | local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id']) | ||
local NS = QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id']) | local NS = NSBydFilter QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id']) | ||
return mw.text.jsonEncode({Mobile=Mobile, NS=NS, args=args},mw.text.JSON_PRESERVE_KEYS) | return mw.text.jsonEncode({Mobile=Mobile, NS=NS, args=args},mw.text.JSON_PRESERVE_KEYS) | ||
end | end | ||
return p | return p |
2022年3月12日 (六) 09:10的版本
可在Module:沙盒/盐棋/Sandbox1/doc创建此模块的帮助文档
local p = {
plat={""," NS"}
}
function LoadJson(filename)
return mw.text.jsonDecode(
mw.getCurrentFrame():expandTemplate{
title = filename
})
end
function QuerySong(json,index,queryById)
if queryById then
for _, v in ipairs(json["songs"]) do
if v['id'] == index then
return v
end
end
else
for _, v in ipairs(json["songs"]) do
if v['title_localized']['en'] == index then
return v
end
end
end
end
function NSBydFilter(info)
local NsBydList={["tempestissimo"] = true}
if info["difficulties"][4] and not NsBydList[info["id"]] then
info["difficulties"][4] = nil
end
return info
end
function p.GetSong(args)
local Mobile = QuerySong(LoadJson("Songlist"),args['曲名'],args['id'])
local NS = NSBydFilter QuerySong(LoadJson("Songlist NS"),args['曲名'],args['id'])
return mw.text.jsonEncode({Mobile=Mobile, NS=NS, args=args},mw.text.JSON_PRESERVE_KEYS)
end
return p