Module:PackSong:修订间差异
Economy666(讨论 | 贡献) 小无编辑摘要 |
Economy666(讨论 | 贡献) 无编辑摘要 |
||
第25行: | 第25行: | ||
local a2z = {} | local a2z = {} | ||
for name in pairs(songList[level]) do table.insert(a2z,name) end | for name in pairs(songList[level]) do table.insert(a2z,name) end | ||
table.sort(a2z) | table.sort(a2z, function(a, b) return string.lower(a) < string.lower(b) end) | ||
for _,name in ipairs(a2z) do | for _,name in ipairs(a2z) do | ||
line = line .. '\n*'..songList[level][name] | line = line .. '\n*'..songList[level][name] |
2024年7月2日 (二) 13:57的版本
可在Module:PackSong/doc创建此模块的帮助文档
local p = {}
local mad = require 'Module:AnotherData'
local function main(packId, plat)
-- packId: base single | plat: mobile ns multi
local songList = {}
for _, song in ipairs(mad.listOf('songs', plat)) do
if song.set == packId then
local ftrDiff = song.difficulties[3] or nil
local level = ftrDiff['rating'] or 0
local plus = ftrDiff['ratingPlus'] and 1 or 0
local levelCate= level*2 + plus -- 7 -> 14 ;7+ -> 15 ...
if not songList[levelCate] then songList[levelCate]={} end
if songList[levelCate][mad.title(song)] then
songList[levelCate][mad.title(song)..song.id] = '[[' .. mad.linkTitle(song) .. ']]'
else
songList[levelCate][mad.title(song)] = '[[' .. mad.linkTitle(song) .. ']]'
end
end
end
local line = ''
for level = 14,22 do -- 7 ~ 11
if songList[level] then
local a2z = {}
for name in pairs(songList[level]) do table.insert(a2z,name) end
table.sort(a2z, function(a, b) return string.lower(a) < string.lower(b) end)
for _,name in ipairs(a2z) do
line = line .. '\n*'..songList[level][name]
end
end
end
return line
end
function p.single(frame)
if frame.args and frame.args['packId'] then
local id = frame.args['packId']
local plat = frame.args['plat'] or 'mobile'
return main(id, plat)
else
return 'No args: packId input!'
end
end
function p.multi(frame)
return 'Under Construction!'
end
return p