Anonymous

Module:Navboxes: Difference between revisions

From Melvor Idle
Fix various issues
(Fix reference to function)
(Fix various issues)
Line 18: Line 18:
for i, recipe in ipairs(SkillData.Farming.recipes) do
for i, recipe in ipairs(SkillData.Farming.recipes) do
local seed = Items.getItemByID(recipe.seedCost.id)
local seed = Items.getItemByID(recipe.seedCost.id)
local product = Items.getItemByID(recipe.productID)
local product = Items.getItemByID(recipe.productId)
local tier = recipe.categoryID
local tier = recipe.categoryID
if seedsTable[tier] == nil then
if seedsTable[tier] == nil then
Line 69: Line 69:
foundIDs[recipe.productID] = true
foundIDs[recipe.productID] = true
if recipe.noMastery == nil then
if recipe.noMastery == nil then
local cookedItem = Items.getItemByID(recipe.itemID)
local cookedItem = Items.getItemByID(recipe.productID)
if cookedItem ~= nil then
if cookedItem ~= nil then
local catIdx = recipe.categoryID
local catIdx = recipe.categoryID
Line 94: Line 94:
for i, recipe in ipairs(SkillData.Farming.recipes) do
for i, recipe in ipairs(SkillData.Farming.recipes) do
if not foundIDs[recipe.productID] then
if not foundIDs[recipe.productID] then
local product = Items.getItemByID(recipe.productID)
local product = Items.getItemByID(recipe.productId)
if product.healsFor ~= nil then
if product.healsFor ~= nil then
table.insert(harvestedFood, { ["name"] = product.name, ["order"] = recipe.level })
table.insert(harvestedFood, { ["name"] = product.name, ["order"] = recipe.level })
Line 127: Line 127:
local getFoodList = function(foodTable)
local getFoodList = function(foodTable)
local listPart = {}
local listPart = {}
for i, food in ipairs(foodTable) do
if type(foodTable) == 'table' then
local foodText = Icons.Icon({food.name, type='item'})
for i, food in ipairs(foodTable) do
if food.perfectName ~= nil then
local foodText = Icons.Icon({food.name, type='item'})
foodText = Icons.Icon({food.perfectName, type='item', notext=true}) .. ' ' .. foodText
if food.perfectName ~= nil then
foodText = Icons.Icon({food.perfectName, type='item', notext=true}) .. ' ' .. foodText
end
table.insert(listPart, foodText)
end
end
table.insert(listPart, foodText)
end
end
return table.concat(listPart, ' • ')
return table.concat(listPart, ' • ')
Line 170: Line 172:
local potFirstItem = Items.getItemByID(potData.potionIDs[1])
local potFirstItem = Items.getItemByID(potData.potionIDs[1])
local potName = string.gsub(potFirstItem.name, ' Potion [IV]+$', '')
local potName = string.gsub(potFirstItem.name, ' Potion [IV]+$', '')
table.insert(potList[potData.category], { ["name"] = potName, ["order"] = potData.level, ["img"] = potFirstItem.name })
table.insert(potList[potData.categoryID], { ["name"] = potName, ["order"] = potData.level, ["img"] = potFirstItem.name })
end
end


Line 240: Line 242:
table.insert(resultPart, '\r\n!colspan="2"|' .. Icons.Icon({'Runes', type='item', img='Air Rune'}))
table.insert(resultPart, '\r\n!colspan="2"|' .. Icons.Icon({'Runes', type='item', img='Air Rune'}))
for i, catID in ipairs(categoryIDs) do
for i, catID in ipairs(categoryIDs) do
local category = GameData.getEntityByID(SkillData.Runecrafting.categories)
local category = GameData.getEntityByID(SkillData.Runecrafting.categories, catID)
if category ~= nil then
if category ~= nil then
table.sort(runeList[catID], function(a, b) return (a.order == b.order and a.name < b.name) or a.order < b.order end)
table.sort(runeList[catID], function(a, b) return (a.order == b.order and a.name < b.name) or a.order < b.order end)
Line 262: Line 264:
local capeNames = {}
local capeNames = {}
for i, cape in ipairs(capeList) do
for i, cape in ipairs(capeList) do
if cape.contains ~= nil and cape.contains.items ~= nil then
capeNames[cape.id] = Shop._getPurchaseName(cape)
local item = Items.getItemByID(cape.contains.items[1].id)
if item ~= nil then
capeNames[cape.id] = item.name
end
end
end
end


table.sort(capeList, function(a, b)
table.sort(capeList, function(a, b)
if a.cost.gp == b.cost.gp then
local costA, costB = Shop._getPurchaseSortValue(a), Shop._getPurchaseSortValue(b)
if costA == costB then
return capeNames[a.id] < capeNames[b.id]
return capeNames[a.id] < capeNames[b.id]
else
else
return a.cost.gp < b.cost.gp
return costA < costB
end
end
end)
end)
Line 292: Line 290:
end
end


-- TODO Add superior skillcapes
function p.getSpellNavbox(frame)
function p.getSpellNavbox(frame)
local spellTable = {}
local spellTable = {}
Line 393: Line 392:
for j, fishID in ipairs(area.fishIDs) do
for j, fishID in ipairs(area.fishIDs) do
local fishItem = Items.getItemByID(fishID)
local fishItem = Items.getItemByID(fishID)
local recipe = GameData.getEntityByID(SkillData.Fishing.recipes, fishID)
local recipe = GameData.getEntityByID(SkillData.Fishing.fish, fishID)
if fishItem ~= nil and recipe ~= nil then
if fishItem ~= nil and recipe ~= nil then
addCatData(area.name, 'Fishing#Fishing Areas', fishItem.name, recipe.level)
addCatData(area.name, 'Fishing#Fishing Areas', fishItem.name, recipe.level)
Line 445: Line 444:
for i, recipe in ipairs(SkillData.Smithing.recipes) do
for i, recipe in ipairs(SkillData.Smithing.recipes) do
if recipe.categoryID == 'melvorD:Bars' then
if recipe.categoryID == 'melvorD:Bars' then
local item = Items.getItemByID(recipe.itemID)
local item = Items.getItemByID(recipe.productID)
if item ~= nil then
if item ~= nil then
local displayName = string.gsub(item.name, ' Bar$', '')
local displayName = string.gsub(item.name, ' Bar$', '')
Line 460: Line 459:
-- Compile list of ores
-- Compile list of ores
for i, recipe in ipairs(SkillData.Mining.rockData) do
for i, recipe in ipairs(SkillData.Mining.rockData) do
if barOreIDs[recipe.productID] then
if barOreIDs[recipe.productId] then
local item = Items.getItemByID(recipe.productID)
local item = Items.getItemByID(recipe.productId)
if item ~= nil then
if item ~= nil then
table.insert(categoryItems['Ores'], { ["name"] = item.name, ["display"] = recipe.name, ["order"] = recipe.level })
table.insert(categoryItems['Ores'], { ["name"] = item.name, ["display"] = recipe.name, ["order"] = recipe.level })