Module:IDInfo/Item

来自Minecraft基岩版开发Wiki
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道如何使用模块,请创建它。
local p = {
	subheader = '物品',
	attributeList = {
		'RawID',
		'NumericID',
		'Experimental',
		'Stackable',
		'CreativeCategory',
		'CreativeGroup',
		'ArmorType',
		'Armor',
		'KnockbackResistance',
		'EnchantType',
		'EnchantAbility',
		'Nutrition',
		'SaturationModifier',
		'Damage',
		'Durability',
		'FuelDuration',
		'Rarity',
		'AllowOffHand',
		'Foil',
		'Renewable',
	},
	infoboxRows = {
		{ label = '原始标识符', field = 1 },
		{ label = '数字标识符', field = 2 },
		{ label = '实验性', field = 3 },
		{ label = '最大堆叠数', field = 4 },
		{ label = '物品栏', field = {
			{ label = '分类', field = 5 },
			{ label = '分组', field = 6 },
		} },
		{ label = '护甲', field = {
			{ label = '护甲类型', field = 7 },
			{ label = '护甲值', field = 8 },
			{ label = '击退抗性', field = 9 },
		} },
		{ label = '附魔', field = {
			{ label = '附魔类型', field = 10 },
			{ label = '附魔能力', field = 11 },
		} },
		{ label = '食用', field = {
			{ label = '饥饿值', field = 12 },
			{ label = '饱和度修饰符', field = 13 },
		} },
		{ label = '伤害', field = 14 },
		{ label = '耐久度', field = 15 },
		{ label = '燃烧时间', field = 16 },
		{ label = '稀有度', field = 17 },
		{ label = '允许双持', field = 18 },
		{ label = '附魔光效', field = 19 },
		{ label = '可再生', field = 20 },
	}
}
function p.format( Attributes )
	local yesno = require( 'Module:IDInfo/Gadget' ).Yesno
	local match = require( 'Module:IDInfo/Gadget' ).Match
	local getIconBar = require( 'Module:IDInfo/Gadget' ).IconBar
	if Attributes.identical.RawID ~= nil then
		Attributes.identical.TileID = Attributes.identical.TileID or ( 'tile.' .. Attributes.identical.RawID )
		Attributes.identical.BlockItemID = Attributes.identical.BlockItemID or Attributes.identical.RawID
	end
	for data, attributes in pairs( Attributes ) do
		Attributes[ data ][ 'Experimental' ] = yesno( attributes.Experimental )
		if attributes.CreativeCategory ~= nil then
			Attributes[ data ][ 'CreativeCategory' ] = match( 'Item/Category', attributes.CreativeCategory, 'id', 'key' )
		else
			Attributes[ data ][ 'CreativeGroup' ] = nil
		end
		if attributes.ArmorType ~= nil then
			attributes.Armor = tonumber( attributes.Armor or Attributes.identical.Armor or 0 )
			if attributes.Armor ~= nil then
				Attributes[ data ][ 'Armor' ] = getIconBar( attributes.Armor, 'Armor.svg', '护甲值' )
			end
			attributes.KnockbackResistance = tonumber( attributes.KnockbackResistance or Attributes.identical.KnockbackResistance or 0 )
			if attributes.KnockbackResistance ~= nil then
				Attributes[ data ][ 'KnockbackResistance' ] = attributes.KnockbackResistance * 100 .. '%'
			end
		elseif Attributes.identical.ArmorType == nil then
			Attributes[ data ][ 'Armor' ] = nil
			Attributes[ data ][ 'KnockbackResistance' ] = nil
		end
		if attributes.EnchantType ~= nil then
			Attributes[ data ][ 'EnchantType' ] = match( 'Item/EnchantType', attributes.EnchantType, 'id', 'key' )
			Attributes[ data ][ 'EnchantAbility' ] = attributes.EnchantAbility or Attributes.identical.EnchantAbility or 1
		elseif Attributes.identical.EnchantType == nil then
			Attributes[ data ][ 'EnchantAbility' ] = nil
		end
		if attributes.Nutrition ~= nil then
			attributes.Nutrition = tonumber( attributes.Nutrition or 0 )
			if attributes.Nutrition ~= nil and attributes.Nutrition ~= 0 then
				Attributes[ data ][ 'Nutrition' ] = getIconBar( attributes.Nutrition, 'Hunger.svg', '饥饿值' )
				Attributes[ data ][ 'SaturationModifier' ] = match( 'Item/SaturationModifier', attributes.SaturationModifier, 'value', 'key' ) or '1.2 (normal)'
			else
				Attributes[ data ][ 'SaturationModifier' ] = nil
			end
		elseif Attributes.identical.Nutrition == nil then
			Attributes[ data ][ 'SaturationModifier' ] = nil
		end
		if attributes.Damage ~= nil then
			attributes.Damage = tonumber( attributes.Damage or 0 )
			if attributes.Damage ~= nil and attributes.Damage ~= 0 then
				Attributes[ data ][ 'Damage' ] = getIconBar( attributes.Damage, 'Heart (icon).png', '生命值' )
			end
		end
		if attributes.Rarity ~= nil then
			Attributes[ data ][ 'Rarity' ] = match( 'Item/Rarity', attributes.Rarity, 'value', 'name' )
		end
		Attributes[ data ][ 'AllowOffHand' ] = yesno( attributes.AllowOffHand )
		Attributes[ data ][ 'Foil' ] = yesno( attributes.Foil, '有', '无' )
		Attributes[ data ][ 'Renewable' ] = yesno( attributes.Renewable )
	end
	return Attributes
end
return p