Module:Items/UseTables: Difference between revisions

_getItemUses: Check for Magic spell uses; add a few overrides
(_getItemUses: Resolve issue where skill use of certain items could be listed twice)
(_getItemUses: Check for Magic spell uses; add a few overrides)
Line 20: Line 20:
Astrology = {'Stardust', 'Golden Stardust'},
Astrology = {'Stardust', 'Golden Stardust'},
Attack = {},
Attack = {},
Combat = {'Gold Emerald Ring'},
Combat = {'Gold Emerald Ring', 'Obsidian Cape', 'Throwing Power Gloves'},
Cooking = {'Cooking Gloves', 'Crown of Rhaelyx'},
Cooking = {'Cooking Gloves', 'Crown of Rhaelyx'},
Crafting = {'Crown of Rhaelyx'},
Crafting = {'Crown of Rhaelyx'},
Line 26: Line 26:
Farming = {'Compost', 'Weird Gloop', 'Bob's Rake'},
Farming = {'Compost', 'Weird Gloop', 'Bob's Rake'},
Firemaking = {'Crown of Rhaelyx'},
Firemaking = {'Crown of Rhaelyx'},
Fishing = {'Amulet of Fishing', 'Message in a Bottle'},
Fishing = {'Amulet of Fishing', 'Message in a Bottle', 'Barbarian Gloves'},
Fletching = {'Crown of Rhaelyx'},
Fletching = {'Crown of Rhaelyx'},
Herblore = {'Crown of Rhaelyx'},
Herblore = {'Crown of Rhaelyx'},
Line 272: Line 272:
if not hasUse(SkillEnum.Prayer) then
if not hasUse(SkillEnum.Prayer) then
addUse(SkillEnum.Prayer)
addUse(SkillEnum.Prayer)
end
end
-- Magic
if not (hasUse('Magic') and hasUse('AltMagic')) then
-- First check if the item its self is used in any spells
local spellList = Magic.getSpellsForItem(item.id, true)
for i, spell in ipairs(spellList) do
local useKey = (spell.type == 'AltMagic' and 'AltMagic' or 'Magic')
if not hasUse(useKey) then
addUse(useKey)
end
end
-- Check if the item provides runes, if it does check where they are used also
if item.providesRune ~= nil then
for i, runeID in ipairs(item.providesRune) do
if hasUse('Magic') and hasUse('AltMagic') then
break
else
local spellList = Magic.getSpellsForItem(runeID, false)
for j, spell in ipairs(spellList) do
local useKey = (spell.type == 'AltMagic' and 'AltMagic' or 'Magic')
if not hasUse(useKey) then
addUse(useKey)
end
end
end
end
end
end
end
end
Line 286: Line 314:
-- And combat skillcapes, since combat skills don't get special treatment
-- And combat skillcapes, since combat skills don't get special treatment
local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'HP Skillcape', 'Defence Skillcape'}
local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'HP Skillcape', 'Defence Skillcape'}
if Shared.contains({'Maximum Skillcape', 'Aorpheat's Signet Ring', 'Cape of Completion'}, item.name) then
if Shared.contains({'Maximum Skillcape', "Aorpheat's Signet Ring", 'Ring of Wealth', 'Cape of Completion'}, item.name) then
addUse('AllSkills')
addUse('AllSkills')
elseif item.name == 'Magic Skillcape' then
elseif item.name == 'Magic Skillcape' then