Module:Inventory slot/Aliases

local loader = require('Module:Loader')

local string, table, uiText, rarityTier = loader.require('String', 'Table', 'UIText', 'RarityTier')

local minionData, ench_data, colorData = loader.loadData('Minion/Data', 'Enchantment/Data', 'Color/Data')

-- Initial values from https://minecraft.gamepedia.com/Module:Inventory_slot/Aliases

local tooltipsTable, templates, itemVariants = loader.require('Inventory slot/Tooltips', 'Inventory_slot/Templates', 'Item/Variants') local aliasesTable, templatesTable, itemVariantsTable = {}, {}, {}

local function getTooltips(keys) if type(keys) == "table" then local ret = {} for i, key in ipairs(keys) do			ret[i] = tooltipsTable[key] or aliasesTable[key] or templatesTable[key] or itemVariantsTable[key] end return ret else return tooltipsTable[keys] or aliasesTable[keys] or templatesTable[keys] or itemVariantsTable[keys] end end

-- Item Tool tips -- -- See https://hypixel.net/threads/guide-minecraft-color-codes.1741307/ -- for information on the color syntax. -- -- Other syntax: -- *\ - New line

-- -- Hypixel Skyblock stuff -- table.merge(aliasesTable, {	-- Fake items	['Air (minion)'] = { title = 'Air', name = 'Minions', image = 'Air (minion)', text = '&7Air should be 1 layer/underneath where the minion/is standing.', link = 'none' },	['Blank'] = { image = 'Black Stained Glass Pane', name = 'none', title = 'none', link='none', text='none' },	['Sell Item'] = { name = 'Hopper', title = '&aSell Item', link='none', text='&7Click items in your inventory to/sell them to the shop!' },	['Close'] = { name = 'Barrier', title = '&cClose', link='none', text='none' },	['Cancel'] = { name = 'Barrier', title = '&cCancel', link='none', text='none' },	['Go Back'] = { name = 'Arrow', title = '&aGo Back', link='none'},	['Next Page'] = { name = 'Arrow', title = '&aNext Page', link='none'},	['Previous Page'] = { name = 'Arrow', title = '&aPrevious Page', link='none'},	['SkyBlock Menu'] = { name = 'SkyBlock Menu', title = '&aSkyBlock Menu &7(Right Click)', text = '&7View all of your SkyBlock/&7progress, including your Skills,/&7Collections, Recipes, and more!//&eClick to open!', }, })

-- Make it so minions tiers use the image, but link to actual page local minions = table.keys(minionData)

table.each(minions, function(name)	local stats = minionData[name].stats	local description = minionData[name].description or 'No Description'	for i,v in ipairs(stats) do		local tier = string._toRoman(i)   	local key = name.." Minion "..tier		aliasesTable[key] = { title = '&9'..key, name = name.." Minion#"..tier, image = key, text = description..'//&7Time Between Action: &a'..v.tba..'s/&7Max Storage: &e'..v.storage }	end end)

-- Make it so enchanted books link to enchantments with href to enchant for name, ench in pairs(ench_data) do   for tier = 1, ench.max, 1 do    	local tier_display = string._toRoman(tier) local key = "Enchanted Book ("..name.." "..tier_display..")" aliasesTable[key] = { title = "Enchanted Book", text=(ench.isUltimate and "&d&l" or "&9")..name.." "..tier_display, name = "Enchantments#".. mw.uri.anchorEncode(name), image = "Enchanted Book" } end end

-- Other colored items -- local colors = colorData.MCColors -- UI Blank (Any Specific Color) -- for _, color in ipairs(colors) do	aliasesTable['Blank ('..color..')'] = { image = color..' Stained Glass Pane', name = 'none', title = 'none', link='none', text='none' } end

for key,values in pairs(templates) do	local default = getTooltips(key) if not default then error('Key '..key..' no default') end if not default.name then error('Key '..key..' no default name') end if not default.title then error('Key '..key..' no default title') end if not default.text then error('Key '..key..' no default text') end local g_id, g_name, g_title, g_text = values.id, default.name, default.title, default.text if type(values) ~= 'table' then values = { values } end for _,item in ipairs(values) do -- ipairs: won't read global settings local repLs = {} local function repl(str) local function _repl(args) for _,sym in ipairs(args) do					str = str:gsub('%$'..sym, repLs[sym] or '') end return str end -- Apply all replacements local allrepl = 'osrl0123456789' local ret = _repl(string.split(allrepl, '')) return ret end local raw, id, name, title, text, vars, rare if type(item) == 'table' then raw = item.id or item[1] id, name, title, text, rare = item.id or g_id or item[1], item.name or g_name, item.title or g_title, item.text or g_text, item.r or item.rarity vars = table.slice(item, 2) else raw, id, name, title, text = item, g_id or item, g_name, g_title, g_text end for i,v in ipairs(type(vars) == 'table' and vars or { vars }) do			repLs[tostring(i-1)] = tostring(v):gsub('%%','%%%%') -- so that it does not incorrectly remove '%'s		end repLs['o'], repLs['s'] = raw, raw id = repl(id) repLs['s'] = id		if rare then repLs['r'] = ('&%s'):format(uiText.getFormatting(rare)) repLs['l'] = ('%s&l%s'):format(repLs['r'], rarityTier._getRarity(rare):upper) end name, title, text = repl(name), repl(title), repl(text) -- Directly insert to tooltips templatesTable[id] = { name=name, title=title, text=text } end end

for k,v in pairs(itemVariants) do	itemVariantsTable[k] = getTooltips(v) end

return table.merge( {}, tooltipsTable, aliasesTable, templatesTable, itemVariantsTable )