跳转到内容

Module:Rotaeno Data:修订间差异

添加649字节 、​ 2022年7月30日 (星期六)
无编辑摘要
无编辑摘要
无编辑摘要
第22行: 第22行:


      -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
      -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
    
 
      if info == nil 
      if info == nil then
     then 
        mw.log('无法在Songlist中发现目标,索引值为:' .. index)
        mw.log( '无法在Songlist中发现目标,索引值为:'..index )
        return nil
        return nil 
      end
      end


第32行: 第31行:
      local switch = {
      local switch = {
        ["id"] = function() return info["id"] end,
        ["id"] = function() return info["id"] end,
        ["title"] = function() return info['title_localized']['default'] end,
        ["title"] = function()
        ["title-en"] = function() return info['title_localized']['en'] end,
         return info['title_localized']['default']
        ["title-zh-Hans"] = function() return info['title_localized']['zh-Hans'] end,
       end,
        ["title-zh-Hant"] = function() return info['title_localized']['zh-Hant'] end,
        ["title-en"] = function()
        ["title-ja"] = function() return info['title_localized']['ja'] end,
         return info['title_localized']['en']
        ["title-ko"] = function() return info['title_localized']['ko'] end,
       end,
        ["title-list"] = function() 
        ["title-zh-Hans"] = function()
          local list = info['title_localized']['default']
         return info['title_localized']['zh-Hans']
          for i,k in pairs(info['title_localized'])
       end,
         do
        ["title-zh-Hant"] = function()
           mw.log(k)
         return info['title_localized']['zh-Hant']
            if k ~= nil and k ~= info['title_localized']['default'] and k ~= "en"
       end,
           then
        ["title-ja"] = function()
              list = list .. "\n" .. k
         return info['title_localized']['ja']
       end,
        ["title-ko"] = function()
         return info['title_localized']['ko']
       end,
        ["title-list"] = function()
          local list = {}
          for i, k in pairs(info['title_localized']) do
            if k ~= nil and k ~= info['title_localized']['default'] and
             k ~= "en" then
              table.insert(list, i .. ":" .. "-{" .. k .. "}-" )
            end
            end
          end
          end
          return list
          
         if #list ~= 0
         then
           return table.concat(list, " | ")
         else
           return nil
         end
        end,
        end,
        ["artist"] = function() return info["artist"] end,
        ["artist"] = function() return info["artist"] end,
第58行: 第73行:
          return info["difficulties"][1]['jacketDesigner']
          return info["difficulties"][1]['jacketDesigner']
        end,
        end,
        ["source"] = function() 
        ["source"] = function()
          if info['source_localized']
          if info['source_localized'] then
         then
            return info['source_localized']['default']
            return info['source_localized']['default'] 
          end
          end
        end,
        end,
第75行: 第89行:
        ["rating4"] = function()
        ["rating4"] = function()
          return info["difficulties"][4]['rating']
          return info["difficulties"][4]['rating']
        end,
        end
      }
      }


      if switch[key] == nil 
      if switch[key] == nil then
     then 
        mw.log('未定义的索引类型,请检查是否拼写错误。')
        mw.log( '未定义的索引类型,请检查是否拼写错误。' )
        return nil
        return nil 
      end
      end


第92行: 第105行:
    -- index:曲目的索引字符串,和typed一致  indexTyped:id或name,查找曲目的索引值类型
    -- index:曲目的索引字符串,和typed一致  indexTyped:id或name,查找曲目的索引值类型


    if indexTyped == "id" then
    if indexTyped == "id" then
      return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), index, 'id')
      return jsonAssayForSingleSong(mw.text.jsonDecode(
                      mw.getCurrentFrame():expandTemplate{
         title = 'Songlist.json'
       }), index, 'id')
    else
    else
      return jsonAssayForSingleSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), index, 'name')
      return jsonAssayForSingleSong(mw.text.jsonDecode(
                      mw.getCurrentFrame():expandTemplate{
         title = 'Songlist.json'
       }), index, 'name')
    end
    end


第106行: 第125行:
    local s, info = "", {}
    local s, info = "", {}
    if indexTyped == "id" then
    if indexTyped == "id" then
      for i, k in ipairs(json['songs']) do
      for i, k in ipairs(json['songs']) do info[k['id']] = k end
       info[k['id']] = k
     end
    else
    else
      for i, k in ipairs(json['songs']) do
      for i, k in ipairs(json['songs']) do
第120行: 第137行:


      -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
      -- 如果info无值即无法在songlist中查找到索引值,则返回nil。
    
 
      if info[index] == nil 
      if info[index] == nil then
     then 
        mw.log('无法在Songlist中发现目标,索引值为:' .. index)
        mw.log( '无法在Songlist中发现目标,索引值为:'..index )
        return nil
        return nil 
      end
      end


第130行: 第146行:
      local switch = {
      local switch = {
        ["id"] = function() return info[index]["id"] end,
        ["id"] = function() return info[index]["id"] end,
        ["title"] = function() return info[index]['title_localized']['default'] end,
        ["title"] = function()
        ["title-en"] = function() return info[index]['title_localized']['en'] end,
         return info[index]['title_localized']['default']
        ["title-zh-Hans"] = function() return info[index]['title_localized']['zh-Hans'] end,
       end,
        ["title-zh-Hant"] = function() return info[index]['title_localized']['zh-Hant'] end,
        ["title-en"] = function()
        ["title-ja"] = function() return info[index]['title_localized']['ja'] end,
         return info[index]['title_localized']['en']
        ["title-ko"] = function() return info[index]['title_localized']['ko'] end,
       end,
        ["title-zh-Hans"] = function()
         return info[index]['title_localized']['zh-Hans']
       end,
        ["title-zh-Hant"] = function()
         return info[index]['title_localized']['zh-Hant']
       end,
        ["title-ja"] = function()
         return info[index]['title_localized']['ja']
       end,
        ["title-ko"] = function()
         return info[index]['title_localized']['ko']
       end,
        ["artist"] = function() return info[index]["artist"] end,
        ["artist"] = function() return info[index]["artist"] end,
        -- Rotaeno谱师画师都一样,所以随便找一个读取
        -- Rotaeno谱师画师都一样,所以随便找一个读取
第144行: 第172行:
          return info[index]["difficulties"][1]['jacketDesigner']
          return info[index]["difficulties"][1]['jacketDesigner']
        end,
        end,
        ["source"] = function() return info[index]['source_localized']['default'] end,
        ["source"] = function()
         return info[index]['source_localized']['default']
       end,
        ["rating1"] = function()
        ["rating1"] = function()
          return info[index]["difficulties"][1]['rating']
          return info[index]["difficulties"][1]['rating']
第156行: 第186行:
        ["rating4"] = function()
        ["rating4"] = function()
          return info[index]["difficulties"][4]['rating']
          return info[index]["difficulties"][4]['rating']
        end,
        end
      }
      }


      if switch[key] == nil 
      if switch[key] == nil then
     then 
        mw.log('未定义的索引类型,请检查是否拼写错误。')
        mw.log( '未定义的索引类型,请检查是否拼写错误。' )
        return nil
        return nil 
      end
      end


第173行: 第202行:
    -- 获得一个查阅信息的函数,可查阅任何曲目。直接在下一个模块使用。
    -- 获得一个查阅信息的函数,可查阅任何曲目。直接在下一个模块使用。
    -- indexTyped:id或name,查找曲目的索引值类型
    -- indexTyped:id或name,查找曲目的索引值类型
    if indexTyped == "id" then
    if indexTyped == "id" then
      return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'id')
      return jsonAssayForAllSong(mw.text.jsonDecode(
                    mw.getCurrentFrame():expandTemplate{
         title = 'Songlist.json'
       }), 'id')
    else
    else
      return jsonAssayForAllSong(mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = 'Songlist.json' } ), 'name')
      return jsonAssayForAllSong(mw.text.jsonDecode(
                    mw.getCurrentFrame():expandTemplate{
         title = 'Songlist.json'
       }), 'name')
    end
    end
end
end