17,030
edits
m (Add space for separator for herb itemsources) |
(Update for v1.3) |
||
Line 4: | Line 4: | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local | local Common = require('Module:Common') | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local SkillData = GameData.skillData | local SkillData = GameData.skillData | ||
local Modifiers = require('Module:Modifiers') | |||
local Skills = require('Module:Skills') | |||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
Line 12: | Line 14: | ||
function p.getCookedItemsTable(frame) | function p.getCookedItemsTable(frame) | ||
local | local args = frame.args ~= nil and frame.args or frame | ||
local category = args[1] | |||
local realmName = args.realm | |||
local realm = Skills.getRealmFromName(realmName) | |||
if realm == nil then | |||
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil')) | |||
end | |||
local skillID = 'Cooking' | |||
local categoryMap = { | local categoryMap = { | ||
["Cooking Fire"] = 'melvorD:Fire', | ["Cooking Fire"] = 'melvorD:Fire', | ||
Line 24: | Line 34: | ||
local recipeArray = GameData.getEntities(SkillData.Cooking.recipes, | local recipeArray = GameData.getEntities(SkillData.Cooking.recipes, | ||
function(recipe) | function(recipe) | ||
return (categoryID == nil or recipe.categoryID == categoryID) and recipe.noMastery == nil | return ( | ||
end) | (categoryID == nil or recipe.categoryID == categoryID) | ||
table.sort(recipeArray, function(a, b) return a | and recipe.noMastery == nil | ||
and Skills.getRecipeRealm(recipe) == realm.id | |||
) | |||
end | |||
) | |||
table.sort(recipeArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end) | |||
-- Logic for generating some cells of the table which are consistent for normal & perfect items | -- Logic for generating some cells of the table which are consistent for normal & perfect items | ||
local getHealingCell = function(item, qty) | local getHealingCell = function(item, qty) | ||
if item ~= nil then | if item ~= nil then | ||
return 'data-sort-value="'..(math.floor(item.healsFor) * qty)..'"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..math.floor(item.healsFor * 10)..(qty > 1 and ' (x'..qty..')' or '') | return 'data-sort-value="'..(math.floor(item.healsFor) * qty)..'"|'..Icons.Icon({"Hitpoints", type="skill", notext=true})..' '..Shared.formatnum(math.floor(item.healsFor * 10))..(qty > 1 and ' (x'..qty..')' or '') | ||
else | else | ||
return ' ' | return ' ' | ||
Line 38: | Line 53: | ||
local getSaleValueCell = function(item, qty) | local getSaleValueCell = function(item, qty) | ||
if item ~= nil then | if item ~= nil then | ||
return 'data-sort-value="'..math.floor(item.sellsFor * qty)..'"|'.. | return 'data-sort-value="'..math.floor(item.sellsFor * qty)..'"|'..Items.getValueText(item)..(qty > 1 and ' (x'..qty..')' or '') | ||
else | else | ||
return ' ' | return ' ' | ||
Line 47: | Line 62: | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | ||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | table.insert(resultPart, '\r\n|- class="headerRow-0"') | ||
table.insert(resultPart, '\r\n!colspan="3" rowspan="2"|Cooked Item!!rowspan="2"| | table.insert(resultPart, '\r\n!colspan="3" rowspan="2"|Cooked Item!!rowspan="2"|Requirements') | ||
table.insert(resultPart, '!!rowspan="2"|Cook Time (s)!!rowspan="2"|XP!!rowspan="2"|XP/s!!colspan="2"|Healing!!colspan="2"|Value!!rowspan="2"|Ingredients') | table.insert(resultPart, '!!rowspan="2"|Cook Time (s)!!rowspan="2"|XP!!rowspan="2"|XP/s!!colspan="2"|Healing!!colspan="2"|Value!!rowspan="2"|Ingredients') | ||
table.insert(resultPart, '\r\n|- class="headerRow-1"') | table.insert(resultPart, '\r\n|- class="headerRow-1"') | ||
Line 54: | Line 69: | ||
for i, recipe in ipairs(recipeArray) do | for i, recipe in ipairs(recipeArray) do | ||
local level = Skills.getRecipeLevel(skillID, recipe) | |||
local baseXP = recipe.baseAbyssalExperience or recipe.baseExperience | |||
local baseInt = recipe.baseInterval / 1000 | |||
local reqText = Skills.getRecipeRequirementText(SkillData.Cooking.name, recipe) | |||
local xpRate = baseXP / baseInt | |||
local item = Items.getItemByID(recipe.productID) | local item = Items.getItemByID(recipe.productID) | ||
local perfectItem = nil | local perfectItem = nil | ||
Line 73: | Line 93: | ||
table.insert(resultPart, Icons.getExpansionIcon(item.id)) | table.insert(resultPart, Icons.getExpansionIcon(item.id)) | ||
table.insert(resultPart, Icons.Icon({item.name, type='item', noicon = true})) | table.insert(resultPart, Icons.Icon({item.name, type='item', noicon = true})) | ||
table.insert(resultPart, '||style="text-align:right"|' .. | table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. level .. '"|' .. reqText) | ||
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. | table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. baseInt .. '"|' .. Shared.round(baseInt, 2, 0)) | ||
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. | table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. baseXP .. '"|' .. Shared.formatnum(baseXP)) | ||
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. xpRate .. '"|' .. Shared.formatnum(Shared.round(xpRate, 2, 0))) | |||
table.insert(resultPart, '||style="text-align:right" data-sort-value="' .. xpRate .. '"|' .. Shared.round(xpRate, 2, 0)) | |||
table.insert(resultPart, '||'..getHealingCell(item, qty)..'||'..getHealingCell(perfectItem, qty)) | table.insert(resultPart, '||'..getHealingCell(item, qty)..'||'..getHealingCell(perfectItem, qty)) | ||
table.insert(resultPart, '||'..getSaleValueCell(item, qty)..'||'..getSaleValueCell(perfectItem, qty)) | table.insert(resultPart, '||'..getSaleValueCell(item, qty)..'||'..getSaleValueCell(perfectItem, qty)) | ||
Line 101: | Line 120: | ||
return potion.customDescription | return potion.customDescription | ||
elseif type(potion.modifiers) == 'table' and not Shared.tableIsEmpty(potion.modifiers) then | elseif type(potion.modifiers) == 'table' and not Shared.tableIsEmpty(potion.modifiers) then | ||
return | return Modifiers.getModifiersText(potion.modifiers, false, true) | ||
else | else | ||
return '' | return '' | ||
Line 108: | Line 127: | ||
function p._getHerblorePotionTable(categoryName) | function p._getHerblorePotionTable(categoryName) | ||
local | local skillID = 'Herblore' | ||
local category = GameData.getEntityByName(SkillData.Herblore.categories, categoryName) | |||
if category == nil then | |||
local catNames = {} | |||
for i, cat in pairs(SkillData.Herblore.categories) do | |||
table.insert(catNames, cat.name) | |||
return Shared.printError('No such | end | ||
return Shared.printError('No such category ' .. categoryName .. ', the following are available: ' .. table.concat(catNames, ', ')) | |||
end | end | ||
local categoryID = category.id | |||
local potionArray = GameData.getEntities(SkillData.Herblore.recipes, | |||
function(potion) | |||
-- Category implies a realm selection, so no ned to check this separately | |||
return potion.categoryID == categoryID | |||
end | |||
) | |||
table.sort(potionArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end) | |||
table.sort(potionArray, function(a, b) return a | |||
local resultPart = {} | local resultPart = {} | ||
table.insert(resultPart, '{|class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{|class="wikitable sortable stickyHeader"') | ||
table.insert(resultPart, '\r\n|- class="headerRow-0"') | table.insert(resultPart, '\r\n|- class="headerRow-0"') | ||
table.insert(resultPart, '\r\n!Potion!! | table.insert(resultPart, '\r\n!Potion!!Requirements') | ||
table.insert(resultPart, '!!XP!!Ingredients!!style="width:30px;"|Tier!!Value!!Charges!!Effect') | table.insert(resultPart, '!!XP!!Ingredients!!style="width:30px;"|Tier!!Value!!Charges!!Effect') | ||
for i, potion in ipairs(potionArray) do | for i, potion in ipairs(potionArray) do | ||
local level = Skills.getRecipeLevel(skillID, potion) | |||
local baseXP = potion.baseAbyssalExperience or potion.baseExperience | |||
local reqText = Skills.getRecipeRequirementText(SkillData.Herblore.name, potion) | |||
local costText = Common.getCostString({ | |||
["items"] = potion.itemCosts, | |||
["currencies"] = potion.currencyCosts | |||
}, 'N/A', nil, ', ') | |||
table.insert(resultPart, '\r\n|-') | table.insert(resultPart, '\r\n|-') | ||
local expIcon = Icons.getExpansionIcon(potion.potionIDs[1]) | local expIcon = Icons.getExpansionIcon(potion.potionIDs[1]) | ||
table.insert(resultPart, '\r\n|rowspan="4"|'..expIcon..'[['..potion.name..']]') | table.insert(resultPart, '\r\n|rowspan="4"|'..expIcon..'[['..potion.name..']]') | ||
table.insert(resultPart, '||rowspan="4" style="text-align:right"|'.. | table.insert(resultPart, '||rowspan="4" style="text-align:right" data-sort-value="' .. level .. '"|'..reqText) | ||
table.insert(resultPart, '||rowspan="4" style="text-align:right" | table.insert(resultPart, '||rowspan="4" style="text-align:right" data-sort-value="' .. baseXP .. '"|'..Shared.formatnum(baseXP)) | ||
table.insert(resultPart, '||rowspan="4"|'..costText..'||') | |||
table.insert(resultPart, '||rowspan="4"|'.. | |||
local tierRows = {} | local tierRows = {} | ||
Line 146: | Line 175: | ||
table.insert(rowTxt, Icons.Icon({tierPot.name, type='item', notext=true})) | table.insert(rowTxt, Icons.Icon({tierPot.name, type='item', notext=true})) | ||
table.insert(rowTxt, Icons.Icon({tierPot.name, tierSuffix[j], type = 'item', noicon=true})) | table.insert(rowTxt, Icons.Icon({tierPot.name, tierSuffix[j], type = 'item', noicon=true})) | ||
table.insert(rowTxt, '||style="text-align:right;" data-sort-value="'..tierPot.sellsFor..'"|'.. | table.insert(rowTxt, '||style="text-align:right;" data-sort-value="'..tierPot.sellsFor..'"|'..Items.getValueText(tierPot)) | ||
table.insert(rowTxt, '||style="text-align:right;"|'..tierPot.charges..'|| '..p._getPotionDescription(tierPot)) | table.insert(rowTxt, '||style="text-align:right;"|'..tierPot.charges..'|| '..p._getPotionDescription(tierPot)) | ||
table.insert(tierRows, table.concat(rowTxt)) | table.insert(tierRows, table.concat(rowTxt)) | ||
Line 158: | Line 187: | ||
function p.getHerblorePotionTable(frame) | function p.getHerblorePotionTable(frame) | ||
local | local args = frame.args ~= nil and frame.args or frame | ||
local category = args[1] | |||
return p._getHerblorePotionTable(category) | return p._getHerblorePotionTable(category) | ||
end | end | ||
function p._getHerbloreHerbTable( | function p._getHerbloreHerbTable(realmID) | ||
local allHerbs = {} | local allHerbs = {} | ||
-- Finds the herb from a potion along with the level required to make the potion. | -- Finds the herb from a potion along with the level required to make the potion. | ||
local function handlePotion(potion) | local function handlePotion(potion) | ||
local potionCosts = potion.itemCosts | local potionCosts = potion.itemCosts | ||
local level = potion | local level = Skills.getRecipeLevel('Herblore', potion) | ||
if potionCosts == nil or level == nil then | if potionCosts == nil or level == nil then | ||
return | return | ||
end | end | ||
-- Find if this potion uses a herb, and which herb it is. | -- Find if this potion uses a herb, and which herb it is. | ||
for _, ingredient in | for _, ingredient in ipairs(potionCosts) do | ||
local ingredientID = ingredient.id | local ingredientID = ingredient.id | ||
if ingredientID | if ingredientID ~= nil and string.sub(ingredientID, -5) == "_Herb" then | ||
-- Set the lowest level of potion this herb is used in. | |||
local currLevel = allHerbs[ingredientID] or 9999999 | |||
if level < currLevel then | |||
allHerbs[ingredientID] = level | |||
end | |||
end | end | ||
end | end | ||
end | end | ||
for _, potion in | local recipes = GameData.getEntities(SkillData.Herblore.recipes, | ||
function(obj) | |||
return Skills.getRecipeRealm(obj) == realmID | |||
end | |||
) | |||
for _, potion in ipairs(recipes) do | |||
handlePotion(potion) | handlePotion(potion) | ||
end | end | ||
Line 219: | Line 251: | ||
:tag("td"):wikitext(herbLevel) | :tag("td"):wikitext(herbLevel) | ||
:tag("td"):wikitext(dlcIcon .. Icons.Icon({herbItem.name, type='item'})) | :tag("td"):wikitext(dlcIcon .. Icons.Icon({herbItem.name, type='item'})) | ||
:tag("td"):wikitext( | :tag("td"):wikitext(Items.getValueText(herbItem)) | ||
:tag('td'):wikitext(ItemSourceTables._getItemSources(herbItem, false, nil, ' ')) | :tag('td'):wikitext(ItemSourceTables._getItemSources(herbItem, false, nil, ' ')) | ||
:done() | :done() | ||
Line 229: | Line 261: | ||
function p.getHerbloreHerbTable(frame) | function p.getHerbloreHerbTable(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
return p._getHerbloreHerbTable( | local realmName = args.realm | ||
local realm = Skills.getRealmFromName(realmName) | |||
if realm == nil then | |||
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil')) | |||
end | |||
return p._getHerbloreHerbTable(realm.id) | |||
end | end | ||
Line 262: | Line 299: | ||
function p.getRunecraftingTable(frame) | function p.getRunecraftingTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
return p._getRecipeTable('Runecrafting', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', ' | return p._getRecipeTable('Runecrafting', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'Currency', 'Ingredients', 'SkillXPSec', 'CurrencySec'}) | ||
end | end | ||
function p.getFletchingTable(frame) | function p.getFletchingTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
return p._getRecipeTable('Fletching', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', ' | return p._getRecipeTable('Fletching', category, {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'Currency', 'Ingredients'}) | ||
end | end | ||
function p.getCraftingTable(frame) | function p.getCraftingTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', ' | local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'Currency', 'Ingredients'} | ||
if category == 'Rings' or category == 'Necklaces' then | if category == 'Rings' or category == 'Necklaces' then | ||
table.insert(columns, "Description") | table.insert(columns, "Description") | ||
Line 281: | Line 318: | ||
function p.getSmithingTable(frame) | function p.getSmithingTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', ' | local columns = {'ItemImage', 'ItemName', 'SkillLevel', 'SkillXP', 'Currency', 'Ingredients'} | ||
if category ~= 'Bars' then | if category ~= 'Bars' and category ~= 'Abyssal Bars' then | ||
table.insert(columns, ' | table.insert(columns, 'CurrencyBar') | ||
end | end | ||
return p._getRecipeTable('Smithing', category, columns) | return p._getRecipeTable('Smithing', category, columns) | ||
Line 292: | Line 329: | ||
-- Note: This only supports a number of skills with consistent recipe data structures, being: | -- Note: This only supports a number of skills with consistent recipe data structures, being: | ||
-- Fletching, Crafting, and Runecrafting | -- Fletching, Crafting, and Runecrafting | ||
-- Valid column list options are: Item, SkillLevel, SkillXP, | -- Valid column list options are: Item, SkillLevel, SkillXP, Currency, Ingredients, SkillXPSec, CurrencySec, CurrencyBar | ||
function p._getRecipeTable(skillName, categoryName, columnList) | function p._getRecipeTable(skillName, categoryName, columnList) | ||
-- Validation: Parameters | -- Validation: Parameters | ||
Line 338: | Line 375: | ||
["SkillLevel"] = {["header"] = Icons.Icon({skillName, type='skill', notext=true}) .. ' Level', ["altRepeat"] = false}, | ["SkillLevel"] = {["header"] = Icons.Icon({skillName, type='skill', notext=true}) .. ' Level', ["altRepeat"] = false}, | ||
["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false}, | ["SkillXP"] = {["header"] = 'XP', ["altRepeat"] = false}, | ||
[" | ["Currency"] = {["header"] = 'Value', ["altRepeat"] = true}, | ||
["Ingredients"] = {["header"] = 'Ingredients', ["altRepeat"] = true}, | ["Ingredients"] = {["header"] = 'Ingredients', ["altRepeat"] = true}, | ||
["SkillXPSec"] = {["header"] = 'XP/s', ["altRepeat"] = false}, | ["SkillXPSec"] = {["header"] = 'XP/s', ["altRepeat"] = false}, | ||
[" | ["CurrencySec"] = {["header"] = 'Value/s', ["altRepeat"] = true}, | ||
[" | ["CurrencyBar"] = {["header"] = 'Value/Bar', ["altRepeat"] = true }, | ||
["Description"] = {["header"] = "Description", ["altRepeat"] = true} | ["Description"] = {["header"] = "Description", ["altRepeat"] = true} | ||
} | } | ||
Line 353: | Line 390: | ||
else | else | ||
table.insert(resultPart, '\r\n! ' .. columnDef[colID].header) | table.insert(resultPart, '\r\n! ' .. columnDef[colID].header) | ||
if colID == ' | if colID == 'CurrencyBar' then | ||
-- For Smithing, a | -- For Smithing, a currency value per bar column is included. If this | ||
-- is requested, then obtain a list of bar item IDs | -- is requested, then obtain a list of bar item IDs | ||
barIDList = p.getBarItemIDs() | barIDList = p.getBarItemIDs() | ||
Line 375: | Line 412: | ||
local ns, _ = GameData.getLocalID(recipe.id) | local ns, _ = GameData.getLocalID(recipe.id) | ||
local item = Items.getItemByID(recipe.productID) | local item = Items.getItemByID(recipe.productID) | ||
local level = Skills.getRecipeLevel(skillName, recipe) | |||
local baseXP = recipe.baseAbyssalExperience or recipe.baseExperience | |||
if item ~= nil then | if item ~= nil then | ||
-- Some recipes have alternative costs, so the recipe may require multiple rows | -- Some recipes have alternative costs, so the recipe may require multiple rows | ||
Line 404: | Line 443: | ||
table.insert(resultPart, '\n|'.. (namePrefix ~= '' and namePrefix .. '| ' or ' ') .. Icons.getExpansionIcon(item.id) .. (qty > 1 and '<b>' .. qty .. 'x</b> ' or '') .. Icons.Icon({item.name, type='item', noicon=true})) | table.insert(resultPart, '\n|'.. (namePrefix ~= '' and namePrefix .. '| ' or ' ') .. Icons.getExpansionIcon(item.id) .. (qty > 1 and '<b>' .. qty .. 'x</b> ' or '') .. Icons.Icon({item.name, type='item', noicon=true})) | ||
elseif colID == 'SkillLevel' then | elseif colID == 'SkillLevel' then | ||
table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' . | table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' .. level) | ||
elseif colID == 'SkillXP' then | elseif colID == 'SkillXP' then | ||
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. | table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. baseXP ..'" style="text-align:right"| ' .. Shared.formatnum(baseXP)) | ||
elseif colID == ' | elseif colID == 'Currency' then | ||
local val = math.floor(item.sellsFor) | local val = math.floor(item.sellsFor) | ||
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. (val * qty) .. '"| ' .. | table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. (val * qty) .. '"| ' .. Items.getValueText(item) .. (qty > 1 and ' (x' .. qty .. ')' or '')) | ||
elseif colID == 'Ingredients' then | elseif colID == 'Ingredients' then | ||
local matArray = {} | local matArray = {} | ||
local currCost = { ["items"] = {}, ["currencies"] = recipe.currencyCosts } | |||
local currText = Common.getCostString(currCost, nil, nil, ', ') | |||
if currText ~= nil then | |||
table.insert(matArray, currText) | |||
end | |||
for k, mat in ipairs(costDef.itemCosts) do | for k, mat in ipairs(costDef.itemCosts) do | ||
local matItem = Items.getItemByID(mat.id) | local matItem = Items.getItemByID(mat.id) | ||
Line 417: | Line 462: | ||
table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.quantity})) | table.insert(matArray, Icons.Icon({matItem.name, type='item', notext=true, qty=mat.quantity})) | ||
end | end | ||
end | end | ||
table.insert(resultPart, '\n|' .. (spanStr ~= '' and spanStr .. '| ' or ' ') .. table.concat(matArray, ', ')) | table.insert(resultPart, '\n|' .. (spanStr ~= '' and spanStr .. '| ' or ' ') .. table.concat(matArray, ', ')) | ||
elseif colID == 'SkillXPSec' then | elseif colID == 'SkillXPSec' then | ||
table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' .. string.format('%.2f', recipe.baseExperience / actionInterval)) | table.insert(resultPart, '\n|' .. spanStr .. 'style="text-align:right"| ' .. string.format('%.2f', recipe.baseExperience / actionInterval)) | ||
elseif colID == ' | elseif colID == 'CurrencySec' then | ||
local saleCurrency = item.sellsForCurrency or 'melvorD:GP' | |||
local val = math.floor(item.sellsFor) * qty / actionInterval | local val = math.floor(item.sellsFor) * qty / actionInterval | ||
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. val .. '"| ' .. Icons. | table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. val .. '"| ' .. Icons._Currency(saleCurrency, string.format('%.2f', val))) | ||
elseif colID == ' | elseif colID == 'CurrencyBar' then | ||
local barQty = 0 | local barQty = 0 | ||
for k, mat in ipairs(costDef.itemCosts) do | for k, mat in ipairs(costDef.itemCosts) do | ||
Line 438: | Line 478: | ||
end | end | ||
if barQty > 0 then | if barQty > 0 then | ||
local saleCurrency = item.sellsForCurrency or 'melvorD:GP' | |||
local barVal = Shared.round(math.floor(item.sellsFor) * qty / barQty, 1, 1) | local barVal = Shared.round(math.floor(item.sellsFor) * qty / barQty, 1, 1) | ||
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. barVal .. '"| ' .. Icons. | table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="' .. barVal .. '"| ' .. Icons._Currency(saleCurrency, barVal)) | ||
else | else | ||
table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="0" class="table-na"| N/A') | table.insert(resultPart, '\n|' .. spanStr .. 'data-sort-value="0" class="table-na"| N/A') | ||
Line 446: | Line 487: | ||
local descrip = Items._getItemStat(item, 'description') | local descrip = Items._getItemStat(item, 'description') | ||
if descrip == 'No Description' and item.modifiers ~= nil and not Shared.tableIsEmpty(item.modifiers) then | if descrip == 'No Description' and item.modifiers ~= nil and not Shared.tableIsEmpty(item.modifiers) then | ||
descrip = | descrip = Modifiers.getModifiersText(item.modifiers, false) | ||
end | end | ||
table.insert(resultPart, '\n| '..spanStr..'|'..descrip) | table.insert(resultPart, '\n| '..spanStr..'|'..descrip) | ||
Line 462: | Line 503: | ||
function p.getBarItemIDs() | function p.getBarItemIDs() | ||
local barCategories = { | |||
['melvorD:Bars'] = true, | |||
['melvorItA:AbyssalBars'] = true | |||
} | |||
local barIDList = {} | local barIDList = {} | ||
for i, recipe in ipairs(SkillData.Smithing.recipes) do | for i, recipe in ipairs(SkillData.Smithing.recipes) do | ||
if recipe.categoryID | if barCategories[recipe.categoryID] then | ||
table.insert(barIDList, recipe.productID) | table.insert(barIDList, recipe.productID) | ||
end | end |