Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement

使用文档请见Template:GameTag/doc

数据模块

  • data:正式版数据模块。
  • snap:快照数据模块。
  • TagType:标签类型配置模块。

数据模块可通过脚本生成(下载:不含实验性内容含实验性内容),使用方法请参阅说明文档

报错分类

local p = {}
local all = mw.text.jsonDecode(mw.getCurrentFrame():expandTemplate{ title = '模块:GameTag/All_js' } )

local i18n = {
	['WrongID'] = "'''未知的ID或无标签'''[[Category:未知的ID]]",
	['WrongTag'] = "'''未知的标签'''[[Category:未知标签]]",
	['WrongType'] = "'''未知的标签类型[[Category:未知标签类型]]'''",
	['Different Group'] = "'''不同标签被分类到一组[[Category:错误合并的标签]]'''"
}

function p.main(f)
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	
	--'blocks','items','entity_types','fluids','game_events'
	
	local objtype
	if args[1] == 'block' or args[1] == 'blocks' then
		objtype='blocks'
	end
	
	if args[1] == 'item' or args[1] == 'items' then
		objtype='items'
	end
	
	if args[1] == 'entity_type' or args[1] == 'entity_types' or args[1] == 'entity'then
		objtype='entity_types'
	end
	
	if args[1] == 'fluid' or args[1] == 'fluids' then
		objtype='fluids'
	end
	
	if args[1] == 'game_event' or args[1] == 'game_events' then
		objtype='game_events'
	end
	
	if not all['tag_ori'][args[1]] and not objtype then
		return i18n['WrongType']
	end
	
	local outtable = {}
	local sptable = {}
	local id = ''
	local diff = false
	local err = ''
	local id = string.gsub(string.lower(args[2] or ''),' ','_')
	
	if args['tagpage'] == '1' or args['tagpage'] == 'y' or args['tagpage'] == 'true' then
		if all['tag_ori'][objtype][id] then
			for i,v in ipairs(all['tag_ori'][objtype][id]) do
				if string.find(v,'#') == 1 then
					table.insert(outtable,
						--[[#blocks flowers|#flowers]]
						table.concat({
							'[[#',
							objtype,
							' ',
							string.sub(v,12),
							'|#',
							string.sub(v,12),
							']]'
							})
						)
				else
					table.insert(outtable,string.sub(v,11))
				end
			end
		else
			return i18n['WrongTag']
		end
		return table.concat(outtable,', ')
	
	else
		if string.find(args[2],',') then
			sptable=mw.text.split(args[2],',')
			id = string.gsub(string.lower(mw.text.trim(sptable[1])),' ','_')
			for i,v in ipairs(sptable) do --all['ID'][objtype][id]
				v = string.gsub(string.lower(mw.text.trim(sptable[i])),' ','_')
				for i1,v1 in ipairs(all['ID'][objtype][id]) do
					if all['ID'][objtype][id] and all['ID'][objtype][v] then
						if v1 ~= all['ID'][objtype][v][i1] then
							diff = diff or true
							err = v
						end
					else
						return i18n['WrongID'].."'''"..id.."'''"
					end
				end
			end
			if diff then
				return i18n['Different Group'].."'''"..err.."'''"
			end
		end
			
		if all['ID'][objtype][id] then
			for i,v in ipairs(all['ID'][objtype][id]) do
				table.insert(outtable,v)
			end
			return table.concat(outtable,',')
		else
			return i18n['WrongID'].."'''"..id.."'''"
		end
	end
end

return p
Advertisement