本站文本内容除另有声明外,转载时均必须注明出处,并遵守CC BY-NC-SA 3.0协议。(转载须知
本站是中文Minecraft Wiki的镜像站,与Mojang Studios、Weird Gloop没有从属关系。(免责声明

全站通知:

模块:Editions

来自我的世界地下城WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块用来生成游戏版本的链接,主要用于{{Editions}}{{In}}{{Only}}

从其他模块调用时,请使用editions函数;从模板调用时,请使用wrapper函数。

函数接受一个Lua table作为参数。其中,数字索引的值用作版本名称;short索引的值指定是否显示为短名称,默认为显示全名;cat索引的值指定要生成的分类名称,版本名称以$代替,默认为$nocat索引的值指定是否不生成分类,默认为生成。

local p = {}

local fullName = mw.loadData([[Module:Editions/FullName]])
local shortName = mw.loadData([[Module:Editions/ShortName]])

function p.editions(args)
	local editionTable = {}
	local categories = {}
	local isShort = args.short
	local nocat = args.nocat
	local catTemplate = args.cat or '$'
	for _, v in ipairs(args) do
		if v ~= '' then
			local name = fullName[mw.ustring.lower(v)] or v .. '版'
			table.insert(editionTable, table.concat {
				'[[',
				name,
				'|',
				isShort and shortName[name] or name,
				']]'
			})
			if not nocat then
				table.insert(
					categories,
					'[[Category:' .. mw.ustring.gsub(catTemplate, '%$', name) .. ']]'
				)
			end
		end
	end
	return mw.text.listToText(editionTable) .. table.concat(categories)
end

function p.wrapper()
	local args = require([[Module:ProcessArgs]]).merge(true)
	return p.editions(args)
end

return p