Module:DesignerSong:修订间差异

添加168字节 、​ 2024年7月24日 (星期三)
无编辑摘要
(创建页面,内容为“p={} local DL = mw.loadJsonData 'User:Economy666/DesignersList.json' local multiId = mw.loadJsonData 'Template:Transition.json'.multiId local trans = mw.loadJsonData 'Template:Transition.json' local mad = require 'Module:AnotherData' local data = require "Module:Arcaea Data" local CL = require 'Module:ConvertLink' local CDL = DL.complex local SDL = DL.simple local specialSong = DL.special local queryMO = data.allSongInformation("id", "mobile") local queryNS…”)
 
无编辑摘要
第127行: 第127行:
end
end


-- Helper function to remove circular references
-- Function to convert table to string
local function removeCircularReferences(tbl, seen)
local function tableToString(tbl, indent)
    seen = seen or {}
    indent = indent or 0
    if seen[tbl] then
    local toPrint = string.rep(" ", indent) .. "{\n"
     return
    
    end
   seen[tbl] = true
    for k, v in pairs(tbl) do
    for k, v in pairs(tbl) do
     local keyString = tostring(k)
     local valueString
      if type(v) == "table" then
      if type(v) == "table" then
        if seen[v] then
        valueString = tableToString(v, indent + 2)
         tbl[k] = nil  -- Remove the circular reference
     else
        else
        valueString = tostring(v)
         removeCircularReferences(v, seen)
       end
      end
      end
     toPrint = toPrint .. string.rep(" ", indent + 2) .. "[" .. keyString .. "] = " .. valueString .. ",\n"
    end
    end
   toPrint = toPrint .. string.rep(" ", indent) .. "}"
   return toPrint
end
end
-- Your main function
-- function p.main()
--   readList()
--   local singleList = genList()
  
--   -- Remove circular references before encoding to JSON
--   removeCircularReferences(singleList)
  
--   return mw.text.jsonEncode(singleList)
-- end


function p.main()
function p.main()
pickList ,specialDesigner = readList()
pickList ,specialDesigner = readList()
singleList = genList(pickList ,specialDesigner)
singleList = genList(pickList ,specialDesigner)
return unpack(singleList)
local list1 =''
for i,ii in pairs(singleList) do
list1 = list1 .. "'''".. i.. "'''" ..'<br><br>'
for j in pairs(ii) do
list1=list1.. j ..'<br>'
end
list1=list1 ..'-------------------------------------------------------------<br>'
end
-- return tableToString(singleList)
return list1
end
end


return p
return p
1,014

个编辑