Module:沙盒/Economy666/Memory Archive NS:修订间差异

来自Arcaea中文维基
无编辑摘要
无编辑摘要
 
(未显示同一用户的3个中间版本)
第1行: 第1行:
local mad = require 'Module:AnotherData'
local mad = require 'Module:AnotherData'
local songlist = mad.listOf 'songs'
local songlistNS = mad.listOf('songs', 'ns')
local songlistNS = mad.listOf('songs', 'ns')


第6行: 第7行:
    local dot = frame:expandTemplate {title = '·'}
    local dot = frame:expandTemplate {title = '·'}
    
    
    local categories = {'poprec', 'partner', 'original', 'variety', 'musicgames', '其他'}
    local categories = {'poprec', 'partner', 'original', 'variety', 'musicgames'}
    local getCategory = {}
    local getCategory = {}
    for i = 1, 6 do
    for i = 1, 5 do
      getCategory[categories[i]] = i
      getCategory[categories[i]] = i
    end
    end
    
    
    local songs = {}
    local songs = {}
    for i = 1, 6 do
    for i = 1, 5 do
      songs[i] = {ns = {}}
      songs[i] = {ns = {}}
    end
    end
    
    
    local nsId = {}
    local nsId = {}
   local mobileId={}
    for i, v in ipairs(songlistNS) do
    for i, v in ipairs(songlistNS) do
      if v.set == 'single' or mad.packQueryWrap(v.set, 'ns')._parentId_ == "single" then
      if v.set == 'single' or mad.packQueryWrap(v.set, 'ns')._parentId_ == "single" then
第24行: 第26行:
    end
    end
    
    
    for i, v in ipairs(songlistNS) do
    for i, v in ipairs(songlist) do
      if v.set == 'single' and nsId[v.id] then
      if v.set == 'single' and nsId[v.id] then
       mobileId[v.id] = true
        local cate = getCategory[v.category]
        local cate = getCategory[v.category]
        if not cate then
        songs[cate].ns[#songs[cate].ns + 1] = v
         cate = 6  -- 将没有分类的歌曲放入 "其他" 分类
       end
       if cate then
         songs[cate].ns[#songs[cate].ns + 1] = v
       end
      end
      end
    end
    end
    
    
    local categoryNames = {'流行/推荐', '搭档', '原创', '综合', '音乐游戏', '其他'}
   for i,v in ipairs(songlistNS) do
if v.set=='single' or mad.packQueryWrap(v.set,'ns')._parentId_=="single" then
if not mobileId[v.id] then
-- 硬编码 gengaozo 等
songs[4].ns[#songs[4].ns+1] = v
end
end
end
  
    local categoryNames = {'流行/推荐', '搭档', '原创', '综合', '音乐游戏'}
    local final = {}
    local final = {}
    for i, v in pairs(frame.args) do
    for i, v in pairs(frame.args) do
第53行: 第60行:
    end
    end


    for i = 1, 6 do
    for i = 1, 5 do
      local list = expand(songs[i].ns)
      local list = expand(songs[i].ns)
      final['group' .. i] = categoryNames[i]
      final['group' .. i] = categoryNames[i]
第59行: 第66行:
    end
    end
    
    
    return frame:expandTemplate{title = 'NS版 曲目索引', args = final}
    return frame:expandTemplate{title = '曲目索引', args = final}
end
end
return p
return p

2024年6月27日 (四) 18:16的最新版本

可在Module:沙盒/Economy666/Memory Archive NS/doc创建此模块的帮助文档

local mad = require 'Module:AnotherData'
local songlist = mad.listOf 'songs'
local songlistNS = mad.listOf('songs', 'ns')

local p = {}
function p.main(frame)
    local dot = frame:expandTemplate {title = '·'}
    
    local categories = {'poprec', 'partner', 'original', 'variety', 'musicgames'}
    local getCategory = {}
    for i = 1, 5 do
        getCategory[categories[i]] = i
    end
    
    local songs = {}
    for i = 1, 5 do
        songs[i] = {ns = {}}
    end
    
    local nsId = {}
    local mobileId={}
    for i, v in ipairs(songlistNS) do
        if v.set == 'single' or mad.packQueryWrap(v.set, 'ns')._parentId_ == "single" then
            nsId[v.id] = true
        end
    end
    
    for i, v in ipairs(songlist) do
        if v.set == 'single' and nsId[v.id] then
            mobileId[v.id] = true
            local cate = getCategory[v.category]
            songs[cate].ns[#songs[cate].ns + 1] = v
        end
    end
    
    for i,v in ipairs(songlistNS) do
		if v.set=='single' or mad.packQueryWrap(v.set,'ns')._parentId_=="single" then 
			if not mobileId[v.id] then
				-- 硬编码 gengaozo 等
				songs[4].ns[#songs[4].ns+1] = v
			end
		end
	end
    
    local categoryNames = {'流行/推荐', '搭档', '原创', '综合', '音乐游戏'}
    local final = {}
    for i, v in pairs(frame.args) do
        final[i] = v
    end

    function expand(t)
        local res = ''
        for i, v in ipairs(t) do
            if i ~= 1 then
                res = res .. dot
            end
            res = res .. '[[' .. mad.linkTitle(v) .. ']]'
        end
        return res
    end

    for i = 1, 5 do
        local list = expand(songs[i].ns)
        final['group' .. i] = categoryNames[i]
        final['list' .. i] = list
    end
    
    return frame:expandTemplate{title = '曲目索引', args = final}
end
return p