跳转到内容

Module:Song:修订间差异

此后如竟没有炬火,我便是唯一的光。
荆哲留言 | 贡献
无编辑摘要
荆哲留言 | 贡献
无编辑摘要
第54行: 第54行:
end
end
local resTable = {}
local resTable = {}
local testStr = ""
for k,v in pairs(sl) do
for k,v in pairs(sl) do
if testStr == "" then
testStr = tostring(type(k)) .. "<br/>\n"
end
resTable[k] = k .. " 号歌曲是"
resTable[k] = k .. " 号歌曲是"
if v.placeholding.tier == "none" or v.placeholding.tier == "weak" then
if v.placeholding.tier == "none" or v.placeholding.tier == "weak" then
第89行: 第93行:
resTable[k] = resTable[k] .. "\n"
resTable[k] = resTable[k] .. "\n"
end
end
local testStr = tostring(#args) .. "个参数。<br>\n"
local i = 3
local i = 3
while true do
while true do
第97行: 第100行:
testStr = testStr .. args[i - 1] .. "号有注释:" .. args[i] .. "<br/>\n"
testStr = testStr .. args[i - 1] .. "号有注释:" .. args[i] .. "<br/>\n"
local key1 = args[i - 1]
local key1 = args[i - 1]
testStr = testStr .. tostring(type(key1)) .. "<br/>\n"
if resTable[key1] ~= nil then
if resTable[key1] ~= nil then
resTable[key1] = resTable[key1] .. "\n" .. args[i] .. "\n"
resTable[key1] = resTable[key1] .. "\n" .. args[i] .. "\n"

2025年3月31日 (一) 12:57的版本

此模块的文档可以在Module:Song/doc创建

local module = {}
local getArgs = require('Module:Arguments').getArgs

local slJson = mw.loadJsonData('Module:Songlist-brief.json')
local ver = slJson.version
local sl = slJson.songlist
local lang = {["qsd"] = "希顶语", ["zxx"] = "纯音乐", ["cmn"] = "国语", ["eng"] = "英语", ["jpn"] = "日语", ["mul"] = "多语种", ["nap"] = "意大利语那不勒斯方言", ["ron"] = "罗马尼亚语", ["yue"] = "粤语"}

function myConcat(l)
	local ret = ""
	local bj = 0
	for k,v in pairs(l) do
		if bj == 0 then
			bj = 1
		else
			ret = ret .. "、"
		end
		ret = ret .. v
	end
	return ret
end

function multilang(str)
    local ret = ""
    local bj = 0
    for field in str:gmatch("([^,]+)") do
    	if bj == 0 then
    		bj = 1
    	else
    		ret = ret .. "、"
    	end
        local tmp = field:match("^%s*(.-)%s*$") -- 去除首尾空格
        local tmp2 = lang[tmp]
        if tmp2 == nil then
        	ret = ret .. "未知语种(" .. tmp .. ")"
        else
        	ret = ret .. tmp2
        end
    end
    return ret
end

function songInfo(song)
	return myConcat(song.singers) .. "的《" .. song.name .. "》"
end

function module.list(frame)
	local args = getArgs(frame)
	local equalSign = args[1]
	if (equalSign == nil) then
		equalSign = 3
	else
		equalSign = tonumber(equalSign)
	end
	local resTable = {}
	local testStr = ""
	for k,v in pairs(sl) do
		if testStr == "" then
			testStr = tostring(type(k)) .. "<br/>\n"
		end
		resTable[k] = k .. " 号歌曲是"
		if v.placeholding.tier == "none" or v.placeholding.tier == "weak" then
			resTable[k] = resTable[k] .. "'''"
		end
		resTable[k] = resTable[k] .. songInfo(v.song)
		if v.placeholding.tier == "none" or v.placeholding.tier == "weak" then
			resTable[k] = resTable[k] .. "'''"
		end
		if v.placeholding.tier ~= "none" then
			resTable[k] = resTable[k] .. ",原版为" .. multilang(v.placeholding.language) .. "版:"
			if v.placeholding.tier == "strong" then
				resTable[k] = resTable[k] .. "'''"
			end
			resTable[k] = resTable[k] .. songInfo(v.placeholding.song)
			if v.placeholding.tier == "strong" then
				resTable[k] = resTable[k] .. "'''"
			end
		end
		resTable[k] = resTable[k] .. "。"
		local bj1 = 0
		for kk, vv in pairs(v.alternatives) do
			if bj1 == 0 then
				bj1 = 1
				resTable[k] = resTable[k] .. "<br/>\n另有"
			else
				resTable[k] = resTable[k] .. "、"
			end
			resTable[k] = resTable[k] .. songInfo(vv)
		end
		if bj1 == 1 then
			resTable[k] = resTable[k] .. "等版本。"
		end
		resTable[k] = resTable[k] .. "\n"
	end
	local i = 3
	while true do
		if args[i - 1] == nil or args[i] == nil then
			break
		end
		testStr = testStr .. args[i - 1] .. "号有注释:" .. args[i] .. "<br/>\n"
		local key1 = args[i - 1]
		testStr = testStr .. tostring(type(key1)) .. "<br/>\n"
		if resTable[key1] ~= nil then
			resTable[key1] = resTable[key1] .. "\n" .. args[i] .. "\n"
		end
		i = i + 2
	end
	local outp = testStr .. "当前歌单数据的版本号为 [[荆哲式流水号|" .. ver .. "]]。\n"
	for k,v in pairs(resTable) do
		outp = outp .. string.rep("=", equalSign) .. k .. "号歌曲" .. string.rep("=", equalSign) .. "\n"
		outp = outp .. v .. "\n"
	end
	return outp
end

return module