Module:Items/UseTables: Difference between revisions

Fix various issues
(Change spellbook -> spellBook to match game data)
(Fix various issues)
Line 379: Line 379:
local rowReq = nil
local rowReq = nil
-- Potions do have upgrade requirements though
-- Potions do have upgrade requirements though
local upgradeItem = Items.GetItemByID(upgrade.upgradedItemID)
local upgradeItem = Items.getItemByID(upgrade.upgradedItemID)
if upgradeItem ~= nil and upgradeItem.charges ~= nil and upgradeItem.tier ~= nil then
if upgradeItem ~= nil and upgradeItem.charges ~= nil and upgradeItem.tier ~= nil then
local levelUnlock = GameData.getEntityByProperty(SkillData.Herblore.masteryLevelUnlocks, 'descriptionID', upgradeItem.tier + 1)
local levelUnlock = GameData.getEntityByProperty(SkillData.Herblore.masteryLevelUnlocks, 'descriptionID', upgradeItem.tier + 1)
Line 450: Line 450:
for i, recipe in ipairs(SkillData.Farming.recipes) do
for i, recipe in ipairs(SkillData.Farming.recipes) do
if recipe.seedCost.id == item.id then
if recipe.seedCost.id == item.id then
local product = Items.getItemByID(recipe.productID)
local product = Items.getItemByID(recipe.productId)
local mat = {{id = recipe.seedCost.id, qty = recipe.seedCost.quantity}}
local mat = {{id = recipe.seedCost.id, quantity = recipe.seedCost.quantity}}
local xp = recipe.baseExperience
local xp = recipe.baseExperience
local rowReq = recipe.level
local rowReq = recipe.level
Line 465: Line 465:
local itemCosts = {}
local itemCosts = {}
for j, itemDef in ipairs(obstacle.itemCosts) do
for j, itemDef in ipairs(obstacle.itemCosts) do
table.insert(itemCosts, {id = itemDef.id, qty = itemDef.quantity})
table.insert(itemCosts, {id = itemDef.id, quantity = itemDef.quantity})
end
end
local req = Agility._getObstacleRequirements(obstacle)
local req = Agility._getObstacleRequirements(obstacle)
Line 496: Line 496:
local recipeCosts = {}
local recipeCosts = {}
for k, itemCost in ipairs(recipe.itemCosts) do
for k, itemCost in ipairs(recipe.itemCosts) do
table.insert(recipeCosts, {id = itemCost.id, qty = itemCost.quantity})
table.insert(recipeCosts, {id = itemCost.id, quantity = itemCost.quantity})
end
end
table.insert(recipeCosts, {id = nonShardItemID, qty = nonShardQty})
table.insert(recipeCosts, {id = nonShardItemID, qty = nonShardQty})
Line 508: Line 508:
for i, shopUse in ipairs(shopUses) do
for i, shopUse in ipairs(shopUses) do
local purchase = shopUse.purchase
local purchase = shopUse.purchase
local rowReq = Shop.getRequirementString(purchase.unlockRequirements)
local rowReq = Shop.getRequirementString(purchase.purchaseRequirements)
local iconType = (purchase.contains.items ~= nil and not Shared.tableIsEmpty(purchase.contains.items) and 'item') or 'upgrade'
local iconType = (purchase.contains.items ~= nil and not Shared.tableIsEmpty(purchase.contains.items) and 'item') or 'upgrade'
local gpCost = Shop.getCurrencyCostString(purchase.cost, 'gp')
local gpCost = Shop.getCurrencyCostString(purchase.cost, 'gp')
local scCost = Shop.getCurrencyCostString(purchase.cost, 'slayerCoins')
local scCost = Shop.getCurrencyCostString(purchase.cost, 'slayerCoins')
local rcCost = Shop.getCurrencyCostString(purchase.cost, 'raidCoins')
local rcCost = Shop.getCurrencyCostString(purchase.cost, 'raidCoins')
table.insert(useArray, {item = {name = Shop._getPurchaseName(purchase)}, qty = shopUse.qty, mats = purchase.cost.items, skill = 'Shop', req = rowReq, xp = 'N/A', gp = gpCost, sc = scCost, rc = rcCost, type = iconType})
table.insert(useArray, {item = {name = Shop._getPurchaseName(purchase)}, qty = 1, mats = purchase.cost.items, skill = 'Shop', req = rowReq, xp = 'N/A', gp = gpCost, sc = scCost, rc = rcCost, type = iconType})
end
end


Line 573: Line 573:
local matItemID = itemCost.id or itemCost[1] or -1
local matItemID = itemCost.id or itemCost[1] or -1
local matItem = Items.getItemByID(matItemID)
local matItem = Items.getItemByID(matItemID)
local matQty = itemCost.qty or itemCost[2] or 1
local matQty = itemCost.quantity or itemCost[2] or 1
if matItem == nil then
if matItem == nil then
table.insert(matRow, 'ERROR: Failed to find item with ID ' .. itemCost.id .. '[[Category:Pages with script errors]]')
table.insert(matRow, 'ERROR: Failed to find item with ID ' .. itemCost.id .. '[[Category:Pages with script errors]]')
Line 595: Line 595:
local scText = nil
local scText = nil
if type(row.sc) == 'number' and row.sc > 0 then
if type(row.sc) == 'number' and row.sc > 0 then
scText = Icons.GP(row.sc)
scText = Icons.SC(row.sc)
elseif type(row.sc) == 'string' then
elseif type(row.sc) == 'string' then
scText = row.sc
scText = row.sc
Line 604: Line 604:
local rcText = nil
local rcText = nil
if type(row.rc) == 'number' and row.rc > 0 then
if type(row.rc) == 'number' and row.rc > 0 then
rcText = Icons.GP(row.rc)
rcText = Icons.RC(row.rc)
elseif type(row.rc) == 'string' then
elseif type(row.rc) == 'string' then
rcText = row.rc
rcText = row.rc
Line 673: Line 673:
table.insert(rowPart, '||'..Icons.Icon({spell.name, type=iconType, noicon=true}))
table.insert(rowPart, '||'..Icons.Icon({spell.name, type=iconType, noicon=true}))
table.insert(rowPart, '||data-sort-value="'..spell.level..'"|'..Magic._getSpellRequirements(spell))
table.insert(rowPart, '||data-sort-value="'..spell.level..'"|'..Magic._getSpellRequirements(spell))
table.insert(rowPart, '||data-sort-value="'..spell.spellBook..'"|')
table.insert(rowPart, '||data-sort-value="'.. spell.spellBook ..'"|')
table.insert(rowPart, Magic.getSpellTypeLink(spell.spellBook))
table.insert(rowPart, Magic.getSpellTypeLink(spell.spellBook))
table.insert(rowPart, '||'..Magic._getSpellStat(spell, 'description'))
table.insert(rowPart, '||'..Magic._getSpellStat(spell, 'description'))