Module:沙盒/盐棋/Sandbox2:修订间差异

来自Arcaea中文维基
(nowiki2)
(try)
第1行: 第1行:
local p = {}
local getArgs = require('Module:Arguments').getArgs


function p.main(frame)
local p={}
return mw.text.nowiki(mw.getCurrentFrame():expandTemplate{ title = ":版本更新日志" })
local W=mw
function LoadJson(filename)
   return W.text.jsonDecode(W.getCurrentFrame():expandTemplate{ title = filename })
end
 
local packPrior,packName=(function ()
local P,N={single = math.maxinteger},{single = 'Memory Archive'}
local contest={['base']=true,['observer']=true,['omatsuri']=true}
local conbine=function(rt,lf)return rt..'#'..rt..' - '..lf..'|'..rt..' - '..lf end
for i,v in ipairs(LoadJson("packlist").packs) do
P[v.id]=i
N[v.id]=v.name_localized.en
if v.pack_parent then
P[v.id]=P[v.pack_parent]
N[v.id]=conbine(N[v.pack_parent],N[v.id])
elseif v.custom_banner and not contest[v.id] then
N[v.id]=N[v.id]..' Collaboration'
end
end
for i,v in ipairs(LoadJson("packlist NS").packs) do
if not N[v.id] and v.pack_parent then--single-append
P[v.id]=P[v.pack_parent]
N[v.id]=conbine(N[v.pack_parent],N[v.id])
end
end
return P,N
end)()
 
function p.main()
return W.text.jsonEncode({packPrior=packPrior, packName=packName},W.text.JSON_PRETTY)
end
end


return p
return p

2022年5月10日 (二) 21:24的版本

可在Module:沙盒/盐棋/Sandbox2/doc创建此模块的帮助文档

local getArgs = require('Module:Arguments').getArgs

local p={}
local W=mw
function LoadJson(filename)
    return W.text.jsonDecode(W.getCurrentFrame():expandTemplate{ title = filename })
end

local packPrior,packName=(function ()
	local P,N={single = math.maxinteger},{single = 'Memory Archive'}
	local contest={['base']=true,['observer']=true,['omatsuri']=true}
	local conbine=function(rt,lf)return rt..'#'..rt..' - '..lf..'|'..rt..' - '..lf end
	for i,v in ipairs(LoadJson("packlist").packs) do
		P[v.id]=i
		N[v.id]=v.name_localized.en
		if v.pack_parent then
			P[v.id]=P[v.pack_parent]
			N[v.id]=conbine(N[v.pack_parent],N[v.id])
		elseif v.custom_banner and not contest[v.id] then
			N[v.id]=N[v.id]..' Collaboration'
		end
	end
	for i,v in ipairs(LoadJson("packlist NS").packs) do
		if not N[v.id] and v.pack_parent then--single-append
			P[v.id]=P[v.pack_parent]
			N[v.id]=conbine(N[v.pack_parent],N[v.id])
		end
	end
	return P,N
end)()

function p.main()
	return W.text.jsonEncode({packPrior=packPrior, packName=packName},W.text.JSON_PRETTY)
end

return p