Module:Inventory slot/Aliases: Difference between revisions

Animations: Added animated potions
Hopefully this works..
Line 637: Line 637:
}
}
local types = {
local types = {
{name = 'Potion',          durations = 'normal',    text = 'Potion of '},
['Potions'] = {
{name = 'Splash Potion',    durations = 'normal',    text = 'Splash Potion of '},
{name = 'Potion',          durations = 'normal',    text = 'Potion of '},
{name = 'Lingering Potion', durations = 'lingering', text = 'Lingering Potion of '},
{name = 'Splash Potion',    durations = 'normal',    text = 'Splash Potion of '},
{name = 'Tipped Arrow',    durations = 'arrow',    text = 'Arrow of '},
{name = 'Lingering Potion', durations = 'lingering', text = 'Lingering Potion of '},
},
['Arrows'] = {
{name = 'Tipped Arrow',    durations = 'arrow',    text = 'Arrow of '},
},
}
}


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