Anonymous

Module:Items/UseTables: Difference between revisions

From Melvor Idle
Tweaked how uses are generated for skills & combat to include modifiers
((Hopefully) fixed issue with items not including Agility Obstacles as a use if no other uses existed)
(Tweaked how uses are generated for skills & combat to include modifiers)
Line 71: Line 71:
   if item.herbloreMasteryID ~= nil then
   if item.herbloreMasteryID ~= nil then
     table.insert(itemUseArray[potionUseArray[item.herbloreMasteryID]], item.name)
     table.insert(itemUseArray[potionUseArray[item.herbloreMasteryID]], item.name)
  end
  --If the item has any modifiers that affect a given skill, add it to those lists
  if item.modifiers ~= nil then
    local skillArray = Constants.getModifierSkills(item.modifiers)
    for i, skillName in Shared.skpairs(skillArray) do
      table.insert(itemUseArray[skillName], item.name)
    end
   end
   end


   --First things added to the list are non-skill things that are easy to check
   --First things added to the list are non-skill things that are easy to check
   if item.equipmentSlot ~= nil or Shared.contains(itemUseArray.Combat, item.name) then
   if Items.hasCombatStats(item) or Shared.contains(itemUseArray.Combat, item.name) then
    if item.equipmentSlot ~= nil then
      --table.insert(categoryArray, '[[Category:'..Items.getEquipmentSlotName(item.equipmentSlot)..' Slot Items]]')
    end
     table.insert(useArray, chr..Icons.Icon({'Combat'}))
     table.insert(useArray, chr..Icons.Icon({'Combat'}))
   end
   end
   if item.healsFor ~= nil then
   if item.healsFor ~= nil then
     table.insert(categoryArray, '[[Category:Food Items]]')
     table.insert(categoryArray, '[[Category:Food Items]]')
     table.insert(useArray, chr..'[[Food]]')
     table.insert(useArray, chr..'[[Food]]')
   end
   end
   if item.dropTable ~= nil then
   if item.dropTable ~= nil then
     table.insert(categoryArray, '[[Category:Openable Items]]')
     table.insert(categoryArray, '[[Category:Openable Items]]')