Module:InventorySlot/Aliases: Difference between revisions

I'm starting to understand how all of this fits together.
(Setup for lore tooltips)
 
(I'm starting to understand how all of this fits together.)
Line 1: Line 1:
local aliases = {
['Clay (block)'] = { title = 'Clay', name = 'Clay (block)' },
['Clay (ball)'] = { title = 'Clay', name = 'Clay (ball)' }
}
-- Tooltip colors --
local yellowTooltips = {
'Creeper Head',
'Damaged Elytra',
'Dragon Head',
'Dragon\'s Breath',
'Elytra',
'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 aquaTooltips = {
'Beacon',
'Conduit',
'Golden Apple',
}
for _, name in ipairs( aquaTooltips ) do
aliases[name] = { title = '&b', name = name }
end


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


-- Potions --
-- Potions --
Line 29: Line 68:
durations = { normal = { '0:20', '0:40', '0:20' }, lingering = { '0:15', '0:45', '0:15' }, arrow = {  '0:07', '0:22', '0:07' }}}
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] ) }
aliases[name .. ' Extended'] = { name = potionName, text = effect.text:gsub( '%$1', durations[2] ) }
aliases[name .. ' Enhanced'] = { name = potionName, text = effect.enhanced:gsub( '%$1', durations[3] ) }
else
-- we always have normal
aliases[name] = { name = potionName, text = string.format( '%s (%s)', effect.effect, durations[1] ) }
-- ensure we have extended
if durations[2] then
aliases[name .. ' Extended'] = { name = potionName, text = string.format( '%s (%s)', effect.effect, durations[2] ) }
-- 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] ) }
end
end
end
else
-- otherwise its just effect, currently every potion with no duration can be enhanced
aliases[name] = { name = potionName, text = effect.effect}
aliases[name .. ' Enhanced'] = { name = potionName, text = effect.effect .. ' ' .. effect.enhanced }
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
Bureaucrats, Check users, emailconfirmed, Interface administrators, staff, Administrators, translation-admin, Widget editors
1,659

edits