Module:PackSong
可在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