17,101
edits
(getPrayerNavbox/getSpellNavbox: Order prayers/spells by level, in line with in-game appearance) |
(getPotionNavbox: Ensure potions sorted by Herblore level requirement & remove 'Potion' name prefix for cleaner appearance) |
||
Line 162: | Line 162: | ||
function p.getPotionNavbox(frame) | function p.getPotionNavbox(frame) | ||
local | local catList = { | ||
{ ["categoryID"] = 0, ["name"] = 'Combat' }, | |||
{ ["categoryID"] = 1, ["name"] = 'Skill' } | |||
} | |||
table.sort(catList, function(a, b) return a.name < b.name end) | |||
-- Compile list of potions to be included | |||
local | local potList = {} | ||
for i, potData in | for i, potData in ipairs(SkillData.Herblore.ItemData) do | ||
if potData.category == | if potList[potData.category] == nil then | ||
potList[potData.category] = {} | |||
end | end | ||
local potFirstItem = Items.getItemByID(potData.itemID[1]) | |||
local potName = string.gsub(potFirstItem.name, ' Potion [IV]+$', '') | |||
table.insert(potList[potData.category], { ["name"] = potName, ["order"] = potData.level, ["img"] = potFirstItem.name }) | |||
end | end | ||
local resultPart = {} | |||
-- Generate table header | |||
table.insert(resultPart, '{| class="wikitable" style="margin:auto; clear:both; width: 100%"') | |||
table.insert(resultPart, '\r\n!colspan=2|' .. Icons.Icon({ 'Herblore', 'Potions', type='skill' })) | |||
-- Generate section for each category of potions | |||
return | for i, catData in ipairs(catList) do | ||
-- Compile list of potions | |||
local potListText = {} | |||
table.sort(potList[catData.categoryID], function(a, b) return (a.order == b.order and a.name < b.name) or a.order < b.order end) | |||
for j, potData in ipairs(potList[catData.categoryID]) do | |||
table.insert(potListText, Icons.Icon({ potData.img, potData.name, type='item' })) | |||
end | |||
table.insert(resultPart, '\r\n|-\r\n! ' .. catData.name .. ' Potions') | |||
table.insert(resultPart, '\r\n|class="center" style="vertical-align:middle;"| ' .. table.concat(potListText, ' • ')) | |||
end | |||
table.insert(resultPart, '\r\n|}') | |||
return table.concat(resultPart) | |||
end | end | ||