Anonymous

Module:Items/UseTables: Difference between revisions

From Melvor Idle
_getItemUseTable: Support GP & SC in various artisan skills
m (Fix Summoning non-shard item cost quantity)
(_getItemUseTable: Support GP & SC in various artisan skills)
(3 intermediate revisions by the same user not shown)
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 94: Line 94:
local addUse = function(useName)
local addUse = function(useName)
local skillID = (type(useName) == 'number' and useName) or SkillEnum[useName]
local skillID = (type(useName) == 'number' and useName) or SkillEnum[useName]
if type(skillID) == 'number' and skillUses[skillID] == nil then
if type(skillID) == 'number' then
skillUses[skillID] = Constants.getSkillName(skillID)
if skillUses[skillID] == nil then
skillUses[skillID] = Constants.getSkillName(skillID)
end
elseif not otherUses[useName] then
elseif not otherUses[useName] then
otherUses[useName] = true
otherUses[useName] = true
Line 270: 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 284: 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
Line 312: Line 342:
local useArray = {}
local useArray = {}
local prefix, delim = asList and '* ' or '', asList and '\r\n' or '<br/>'
local prefix, delim = asList and '* ' or '', asList and '\r\n' or '<br/>'
for skillID, skillName in Shared.spairs(skillUses, function(t, a, b) return t[a] < t[b] end) do
table.insert(useArray, prefix .. Icons.Icon({skillName, type='skill'}))
end
for use, _ in Shared.skpairs(otherUses) do
for use, _ in Shared.skpairs(otherUses) do
table.insert(useArray, prefix .. (otherUseText[use] or use))
table.insert(useArray, prefix .. (otherUseText[use] or use))
end
for skillID, skillName in Shared.spairs(skillUses, function(t, a, b) return t[a] < t[b] end) do
table.insert(useArray, prefix .. Icons.Icon({skillName, type='skill'}))
end
end


Line 404: Line 434:
end
end
end
end
table.insert(useArray, {item = itemDef, qty = qty, mats = costDef.itemCosts, skill = skillName, reqVal = reqVal, req = rowReq, xp = recipe.baseXP})
table.insert(useArray, {item = itemDef, qty = qty, mats = costDef.itemCosts, gp = recipe.gpCost, sc = recipe.scCost, skill = skillName, reqVal = reqVal, req = rowReq, xp = recipe.baseXP})
end
end
end
end
Line 673: Line 703:
'Mysterious Stone',
'Mysterious Stone',
'Mastery Token (Cooking)',
'Mastery Token (Cooking)',
'Gem Gloves'
'Gem Gloves',
'Basic Bag'
}
}
local checkFuncs = {
local checkFuncs = {