Module:InventorySlot/Aliases: Difference between revisions
Jump to navigation
Jump to search
(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 |
Revision as of 05:36, 9 August 2020
Documentation for this module may be created at Module:InventorySlot/Aliases/doc
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 --
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] ) }
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