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

来自Arcaea中文维基
(fix)
(pack)
 
(未显示同一用户的38个中间版本)
第1行: 第1行:
local getArgs = require('Module:Arguments').getArgs
local p = { single = { idx = -100, name = "Memory Archive" } }
 
local plst = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate { title = "packlist" }).packs
local p={}
local special = { base = true, omatsuri = true, observer = true }
local W=mw
for i, v in ipairs(plst) do
function LoadJson(filename)
local co = v.custom_banner and not special[v.id]
   return W.text.jsonDecode(W.getCurrentFrame():expandTemplate{ title = filename })
local name = v.name_localized.en
end
if co then name = name .. " Collaboration" end
 
if (p[v.pack_parent or ""] or p.single).name:find " Collaboration" then
local packPrior,packName=(function ()
name = p[v.pack_parent].name .. " - " .. name
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],v.name_localized.en)
end
end
end
return P,N
p[v.id] = { idx = i, name = name }
end)()
 
function p.main()
return W.text.jsonEncode({packPrior=packPrior, packName=packName},W.text.JSON_PRETTY)
end
end
return p
return p

2022年9月16日 (五) 15:30的最新版本

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

local p = { single = { idx = -100, name = "Memory Archive" } }
local plst = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate { title = "packlist" }).packs
local special = { base = true, omatsuri = true, observer = true }
for i, v in ipairs(plst) do
	local co = v.custom_banner and not special[v.id]
	local name = v.name_localized.en
	if co then name = name .. " Collaboration" end
	if (p[v.pack_parent or ""] or p.single).name:find " Collaboration" then
		name = p[v.pack_parent].name .. " - " .. name
	end
	p[v.id] = { idx = i, name = name }
end
return p