Module:InventorySlot/Aliases

Revision as of 02:38, 15 February 2021 by Epyon (talk | contribs) (enchanted = true, not yes)

Documentation for this module may be created at Module:InventorySlot/Aliases/doc

local aliases = {
    ['Broken Elytra'] = { title = '&eElytra', name = 'Broken Elytra' },
	['Clay (block)'] = { title = 'Clay', name = 'Clay (block)' }, 
	['Clay (ball)'] = { title = 'Clay', name = 'Clay (ball)' },
	['Iron Block'] = { title = 'Block of Iron', name = 'Block of Iron' }, 
	['Gold Block'] = { title = 'Block of Gold', name = 'Block of Gold' }, 
	['Diamond Block'] = { title = 'Block of Diamond', name = 'Block of Diamond' }
}


-- Tooltip colors --
local yellowTooltips = {
	'Creeper Head',
	'Damaged Elytra',
	'Dragon Head',
	'Dragon\'s Breath',
	'Elytra',
	'Enchanted Book',
	'Head',
	'Heart of the Sea',
	'Player Head',
	'Skeleton Skull',
	'Totem of Undying',
	'Wither Skeleton Skull',
	'Zombie Head',
}
for _, name in ipairs( yellowTooltips ) do
	aliases[name] = { title = '&e', name = name }
end

local enchantedIconYellowTooltips = {
	'Bottle o\' Enchanting',
	'Enchanted Book',
	'Nether Star'
}

for _, name in ipairs( enchantedIconYellowTooltips ) do
	aliases[name] = { title = '&e', name = name, enchanted = true }
end

local aquaTooltips = {
	'Beacon',
	'Conduit',
	'Golden Apple',
}
for _, name in ipairs( aquaTooltips ) do
	aliases[name] = { title = '&b', name = name }
end

local enchantedIconAquaTooltips = {
	'End Crystal'
}

for _, name in ipair( enchantedIconAquaTooltips ) do
	aliases[name] = { title = '&b', name = name, enchanted = true }
end

local lightPurpleTooltips = {
	'Dragon Egg',
	'Structure Block',
}

for _, name in ipairs( lightPurpleTooltips ) do
	aliases[name] = { title = '&d', name = name }
end

local enchantedIconPurpleTooltips = {
	'Enchanted Golden Apple'
}

for _, name in ipairs( enchantedIconPurpleTooltips ) do
	aliases[name] = { title = '&d', name = name, enchanted = true }
end

-- Discs --
local discs = { 
	{ '13',      'C418',                 },
	{ 'Cat',     'C418',       'cat'     },
	{ 'Blocks',  'C418',       'blocks'  },
	{ 'Chirp',   'C418',       'chirp'   },
	{ 'Far',     'C418',       'far'     },
	{ 'Mall',    'C418',       'mall'    },
	{ 'Mellohi', 'C418',       'mellohi' },
	{ 'Stal',    'C418',       'stal'    },
	{ 'Strad',   'C418',       'strad'   },
	{ 'Ward',    'C418',       'ward'    },
	{ '11',      'C418',                 },
	{ 'Wait',    'C418',       'wait'    },
	{ 'Pigstep', 'Lena Raine',           },
}
for _, disc in ipairs( discs ) do
	local name = 'Music Disc ' .. disc[1]
	local artist = disc[2]
	local trackname = disc[1]
	if disc[3] ~= nil then
		trackname = disc[3]
	end
	aliases[name] = { title = '&bMusic Disc', name = name, text = '&7' .. artist .. ' - ' .. trackname }
end

-- Armour
local armour = {
	{'Turtle', 'Shell', 2, 0 },
	{'Leather', 'Cap', 1, 0 },
	{'Golden', 'Helmet', 2, 0 },
	{'Chainmail', 'Helmet', 2, 0 },
	{'Iron', 'Helmet', 2, 0 },
	{'Diamond', 'Helmet', 3, 2 },
	{'Netherite', 'Helmet', 3, 3 },


	{'Leather', 'Tunic', 3, 0 },
	{'Golden', 'Chestplate', 5, 0 },
	{'Chainmail', 'Chestplate', 5, 0 },
	{'Iron', 'Chestplate', 6, 0 },
	{'Diamond', 'Chestplate', 8, 2 },
	{'Netherite', 'Chestplate', 8, 3 },
	
	{'Leather', 'Pants', 2, 0 },
	{'Golden', 'Leggings', 3, 0 },
	{'Chainmail', 'Leggings', 4, 0 },
	{'Iron', 'Leggings', 5, 0 },
	{'Diamond', 'Leggings', 6, 2 },
	{'Netherite', 'Leggings', 6, 3 },
	
	{'Leather', 'Boots', 1, 0 },
	{'Golden', 'Boots', 1, 0 },
	{'Chainmail', 'Boots', 1, 0 },
	{'Iron', 'Boots', 2, 0 },
	{'Diamond', 'Boots', 3, 2 },
	{'Netherite', 'Boots', 3, 3 }
}

for _, armourProps in ipairs( armour ) do
	local aliasName = armourProps[1] .. ' ' .. armourProps[2]

	local armourSlotText = '/&7When on '

	if armourProps[2] == 'Shell' or armourProps[2] == 'Cap' or armourProps[2] == 'Helmet' then
		armourSlotText = armourSlotText .. 'head'

	elseif armourProps[2] == 'Tunic' or armourProps[2] == 'Chestplate' then
		armourSlotText = armourSlotText .. 'body'

	elseif armourProps[2] == 'Pants' or armourProps[2] == 'Leggings' then
		armourSlotText = armourSlotText .. 'legs'
	else
		armourSlotText = armourSlotText .. 'feet'
	end

	armourSlotText = armourSlotText .. ':/&9+'

	-- If Armour Toughness (diamond or netherite armour)
	if armourProps[4] ~= 0 then
		aliases[aliasName] = { title = aliasName, name = aliasName, text = armourSlotText .. armourProps[4] .. ' Armour Toughness/+' .. armourProps[3] .. ' Armour' }
	-- No Armour Toughness (all other armour)
	else
		aliases[aliasName] = { title = aliasName, name = aliasName, text = armourSlotText .. armourProps[3] .. ' Armour' }
	end
end



-- Tools and weapons --
local tools = {
	{'Wooden', 'Sword', 1.6, 4 },
	{'Stone', 'Sword', 1.6, 5 },
	{'Iron', 'Sword', 1.6, 6 },
	{'Golden', 'Sword', 1.6, 4 },
	{'Diamond', 'Sword', 1.6, 7 },
	{'Netherite', 'Sword', 1.6, 8 },
	
	{'Wooden', 'Pickaxe', 1.2, 2 },
	{'Stone', 'Pickaxe', 1.2, 3 },
	{'Iron', 'Pickaxe', 1.2, 4 },
	{'Golden', 'Pickaxe', 1.2, 2 },
	{'Diamond', 'Pickaxe', 1.2, 5 },
	{'Netherite', 'Pickaxe', 1.2, 6 },
	
	{'Wooden', 'Axe', 0.8, 7 },
	{'Stone', 'Axe', 0.8, 9 },
	{'Iron', 'Axe', 0.9, 9 },
	{'Golden', 'Axe', 1, 7 },
	{'Diamond', 'Axe', 1, 9 },
	{'Netherite', 'Axe', 1, 9 },
	
	{'Wooden', 'Shovel', 1, 2.5 },
	{'Stone', 'Shovel', 1, 3.5 },
	{'Iron', 'Shovel', 1, 4.5 },
	{'Golden', 'Shovel', 1, 2.5 },
	{'Diamond', 'Shovel', 1, 5.5 },
	{'Netherite', 'Shovel', 1.6, 6.5 },
	
	{'Wooden', 'Hoe', 1, 1 },
	{'Stone', 'Hoe', 2, 1 },
	{'Iron', 'Hoe', 3, 1 },
	{'Golden', 'Hoe', 1, 1 },
	{'Diamond', 'Hoe', 4, 1 },
	{'Netherite', 'Hoe', 4, 1 }
}


for _, toolProps in ipairs( tools ) do
	local aliasName = toolProps[1] .. ' ' .. toolProps[2]
	aliases[aliasName] = { title = aliasName, name = aliasName, text = '/&7When in main hand:/&2 ' .. toolProps[3] .. ' Attack Speed/&2 ' .. toolProps[4] .. ' Attack Damage' }
end



-- list of all potions with no effects
local noEffects = {
	'Water Bottle',
	'Awkward Potion',
	'Thick Potion',
	'Mundane Potion',
	'Uncraftable Potion',
	'Splash Water Bottle',
	'Awkward Splash Potion',
	'Thick Splash Potion',
	'Mundane Splash Potion',
	'Uncraftable Splash Potion',
	'Lingering Water Bottle',
	'Awkward Lingering Potion',
	'Thick Lingering Potion',
	'Mundane Lingering Potion',
	'Uncraftable Lingering Potion',
	'Tipped Arrow',
	'Arrow of Splashing',
	'Uncraftable Tipped Arrow',
}
for _, name in ipairs(noEffects) do
	aliases[name] = { name = name, text = '&7No effects' }
end

-- start these lists with the no effect items as names are not normal
local potionItems = {
	['Potion'] = {
		aliases['Water Bottle'],
		aliases['Awkward Potion'],
		aliases['Thick Potion'],
		aliases['Mundane Potion'],
	},
	['Splash Potion'] = {
		aliases['Splash Water Bottle'],
		aliases['Awkward Splash Potion'],
		aliases['Thick Splash Potion'],
		aliases['Mundane Splash Potion'],
	},
	['Lingering Potion'] = {
		aliases['Lingering Water Bottle'],
		aliases['Awkward Lingering Potion'],
		aliases['Thick Lingering Potion'],
		aliases['Mundane Lingering Potion'],
	},
	['Tipped Arrow'] = {
		aliases['Arrow of Splashing'],
		aliases['Tipped Arrow'],
		aliases['Tipped Arrow'],
		aliases['Tipped Arrow'],
	},
}

-- Potions --
local effects = {
	-- durations are in the order normal, extended, enhanced
	{name = 'Regeneration', effect = '&9Regeneration', enhanced = 'II',
		durations = { normal = { '0:45', '1:30', '0:22' }, lingering = { '0:11', '0:22', '0:05' }, arrow = { '0:05', '0:11', '0:02' }}},
	{ name = 'Swiftness', effect = '&9Speed', enhanced = 'II', 
		durations = { normal = { '3:00', '8:00', '1:30' }, lingering = { '0:45', '2:00', '0:22' }, arrow = { '0:22', '1:00', '0:11' }}},
	{ name = 'Fire Resistance', effect = '&9Fire Resistance', durations = { normal = { '3:00', '8:00' }, lingering = { '0:45', '2:00' }, arrow = { '0:22', '1:00' }}},
	{ name = 'Poison', effect = '&cPoison', enhanced = 'II', 
		durations = { normal = { '0:45', '1:30', '0:21' }, lingering = { '0:11', '0:22', '0:05' }, arrow = { '0:05', '0:11', '0:02' }}},
	{ name = 'Healing', effect = '&9Instant Health', enhanced = 'II' },
	{ name = 'Night Vision',    effect = '&9Night Vision',    durations = { normal = { '3:00', '8:00' }, lingering = { '0:45', '2:00' }, arrow = { '0:22', '1:00' }}},
	{ name = 'Weakness',        effect = '&cWeakness',        durations = { normal = { '1:30', '4:00' }, lingering = { '0:22', '1:00' }, arrow = { '0:11', '0:30' }}},
	{ name = 'Strength', effect = '&9Strength', enhanced = 'II', 
		durations = { normal = { '3:00', '8:00', '1:30'}, lingering = {'0:45', '2:00', '0:22'}, arrow = { '0:22', '1:00', '0:11' }}},
	{ name = 'Slowness', effect = '&cSlowness', enhanced = 'IV', 
		durations = { normal = { '1:30', '4:00', '0:20'}, lingering = {'0:22', '1:00', '0:05'}, arrow = { '0:11', '0:30', '0:02' }}},
	{ name = 'Leaping', effect = '&9Jump Boost', enhanced = 'II', 
		durations = { normal = { '3:00', '8:00', '1:30' }, lingering = {'0:45', '2:00', '0:22'}, arrow = { '0:22', '1:00', '0:11' }}},
	{ name = 'Harming', effect = '&cInstant Damage', enhanced = 'II' },
	{ name = 'Water Breathing', effect = '&9Water Breathing', durations = { normal = { '3:00', '8:00' }, lingering = { '0:45', '2:00' }, arrow = { '0:22', '1:00' }}},
	{ name = 'Invisibility',    effect = '&9Invisibility',    durations = { normal = { '3:00', '8:00' }, lingering = { '0:45', '2:00' }, arrow = { '0:22', '1:00' }}},
	{ name = 'Slow Falling',    effect = '&9Slow Falling',    durations = { normal = { '1:30', '4:00' }, lingering = { '0:22', '1:00' }, arrow = { '0:11', '0:30' }}},
	{ name = 'Luck',  effect = '&9Luck',   durations = { normal = { '5:00' }, lingering = { '1:15' }, arrow = { '0:37' }}},
	{ name = 'Decay', effect = '&cWither', durations = { normal = { '0:40' }, lingering = { '0:10' }, arrow = { '0:05' }}},
	{ name = 'the Turtle Master', text = '&cSlowness IV ($1)/&9Resistance III ($1)', enhanced = '&cSlowness VI ($1)/&9Resistance IV ($1)',
		durations = { normal = { '0:20', '0:40', '0:20' }, lingering = { '0:15', '0:45', '0:15' }, arrow = {  '0:07', '0:22', '0:07' }}}
}

local types = {
	{name = 'Potion',           durations = 'normal',    text = 'Potion of '},
	{name = 'Splash Potion',    durations = 'normal',    text = 'Splash Potion of '},
	{name = 'Lingering Potion', durations = 'lingering', text = 'Lingering Potion of '},
	{name = 'Tipped Arrow',     durations = 'arrow',     text = 'Arrow of '},
}

for _, effect in ipairs(effects) do
	for _, type in ipairs(types) do
		-- form name, it will be reused
		local name =  type.text .. effect.name
		local potionName = {}
		--if type.name == 'Tipped Arrow' then
		potionName = type.text .. effect.name
		--else
		--potionName = type.text .. effect.name .. '.gif'
		--end
		
		-- if we have durations, add times
		if effect.durations then
			local durations = effect.durations[type.durations]
			
			-- turtle master is weird, so just do a fancy string replacement
			if effect.text then
				aliases[name] = { name = potionName, text = effect.text:gsub( '%$1', durations[1] ), enchanted = true }
				aliases[name .. ' Extended'] = { name = potionName, text = effect.text:gsub( '%$1', durations[2] ), enchanted = true }
				aliases[name .. ' Enhanced'] = { name = potionName, text = effect.enhanced:gsub( '%$1', durations[3] ), enchanted = true }
			else
				-- we always have normal
				aliases[name] = { name = potionName, text = string.format( '%s (%s)', effect.effect, durations[1] ), enchanted = true }
			
				-- ensure we have extended
				if durations[2] then
					aliases[name .. ' Extended'] = { name = potionName, text = string.format( '%s (%s)', effect.effect, durations[2] ), enchanted = true }
					
					-- and enhanced, currently there is nothing with a duration that can be extended but not enhanced
					if effect.enhanced then
						aliases[name .. ' Enhanced'] = { name = potionName, text = string.format( '%s %s (%s)', effect.effect, effect.enhanced, durations[3] ), enchanted = true }
					end
				end
			end
		else
			-- otherwise its just effect, currently every potion with no duration can be enhanced
			aliases[name] = { name = potionName, text = effect.effect, enchanted = yes }
			aliases[name .. ' Enhanced'] = { name = potionName, text = effect.effect .. ' ' .. effect.enhanced, enchanted = true }
		end
		
		-- add the base potion to the any list
		table.insert(potionItems[type.name], aliases[name])
	end
end

-- build the any lists
for item, potionAliases in pairs( potionItems ) do
	aliases['Any ' .. item] = potionAliases
	aliases['Matching ' .. item] = potionAliases
end


return aliases