Anonymous

Module:Items/UseTables: Difference between revisions

From Melvor Idle
Added asList argument to getItemUses
(Added agility override to item use array)
(Added asList argument to getItemUses)
Line 60: Line 60:
}
}


function p._getItemUses(item, addCategories)
function p._getItemUses(item, asList, addCategories)
   local useArray = {}
   local useArray = {}
   local categoryArray = {}
   local categoryArray = {}
  local chr = asList and '* ' or ''
   --Another fun one. This time getting all the different possible ways an item can be used
   --Another fun one. This time getting all the different possible ways an item can be used


Line 75: Line 76:
       --table.insert(categoryArray, '[[Category:'..Items.getEquipmentSlotName(item.equipmentSlot)..' Slot Items]]')  
       --table.insert(categoryArray, '[[Category:'..Items.getEquipmentSlotName(item.equipmentSlot)..' Slot Items]]')  
     end
     end
     table.insert(useArray, '* '..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, '* [[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]]')
     table.insert(useArray, '* [[Chest Drop Tables|Can Be Opened]]')  
     table.insert(useArray, chr..'[[Chest Drop Tables|Can Be Opened]]')  
   end
   end


Line 146: Line 147:
       table.insert(categoryArray, '[[Category:Upgradeable Items]]')
       table.insert(categoryArray, '[[Category:Upgradeable Items]]')
     end
     end
     table.insert(useArray, '* [[Upgrading Items]]')
     table.insert(useArray, chr..'[[Upgrading Items]]')
   end
   end
    
    
   --Agility
   --Agility
   if Shared.contains(itemUseArray.Agility, item.name) then
   if Shared.contains(itemUseArray.Agility, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Agility', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Agility', type='skill'}))
   end
   end
   --Cooking
   --Cooking
   if item.cookedItemID ~= nil or Shared.contains(itemUseArray.Cooking, item.name) then
   if item.cookedItemID ~= nil or Shared.contains(itemUseArray.Cooking, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Cooking', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Cooking', type='skill'}))
   end
   end
   --Crafting
   --Crafting
   if canCraft or Shared.contains(itemUseArray.Crafting, item.name) then
   if canCraft or Shared.contains(itemUseArray.Crafting, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Crafting', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Crafting', type='skill'}))
   end
   end
   --Farming
   --Farming
   if item.grownItemID ~= nil or Shared.contains(itemUseArray.Farming, item.name) then
   if item.grownItemID ~= nil or Shared.contains(itemUseArray.Farming, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Farming', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Farming', type='skill'}))
   end
   end
   --Firemaking
   --Firemaking
   if item.firemakingID ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then
   if item.firemakingID ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Firemaking', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'}))
   end
   end
   --Fishing
   --Fishing
   if Shared.contains(itemUseArray.Fishing, item.name) then
   if Shared.contains(itemUseArray.Fishing, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Fishing', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Fishing', type='skill'}))
   end
   end
   --Fletching
   --Fletching
   if canFletch or Shared.contains(itemUseArray.Fletching, item.name) then
   if canFletch or Shared.contains(itemUseArray.Fletching, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Fletching', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Fletching', type='skill'}))
   end
   end
   --Herblore
   --Herblore
   if canHerblore or Shared.contains(itemUseArray.Herblore, item.name) then
   if canHerblore or Shared.contains(itemUseArray.Herblore, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Herblore', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Herblore', type='skill'}))
   end
   end
   --Mining
   --Mining
   if Shared.contains(itemUseArray.Mining, item.name) then
   if Shared.contains(itemUseArray.Mining, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Mining', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Mining', type='skill'}))
   end
   end
   --Prayer
   --Prayer
   if item.prayerPoints ~= nil or Shared.contains(itemUseArray.Prayer, item.name) then
   if item.prayerPoints ~= nil or Shared.contains(itemUseArray.Prayer, item.name) then
     if item.prayerPoints ~= nil then table.insert(categoryArray, '[[Category:Buriable Items]]') end
     if item.prayerPoints ~= nil then table.insert(categoryArray, '[[Category:Buriable Items]]') end
     table.insert(useArray, '* '..Icons.Icon({'Prayer', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Prayer', type='skill'}))
   end
   end
   --Runecrafting
   --Runecrafting
   if canRunecraft or Shared.contains(itemUseArray.Runecrafting, item.name) then
   if canRunecraft or Shared.contains(itemUseArray.Runecrafting, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Runecrafting', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Runecrafting', type='skill'}))
   end
   end
   --Slayer
   --Slayer
   if item.slayerCost ~= nil or Shared.contains(itemUseArray.Slayer, item.name) then
   if item.slayerCost ~= nil or Shared.contains(itemUseArray.Slayer, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Slayer', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Slayer', type='skill'}))
   end
   end
   --Smithing
   --Smithing
   if item.type == 'Bar' or item.type == 'Ore' or Shared.contains(itemUseArray.Smithing, item.name) then
   if item.type == 'Bar' or item.type == 'Ore' or Shared.contains(itemUseArray.Smithing, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Smithing', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Smithing', type='skill'}))
   end
   end
   --Thieving
   --Thieving
   if Shared.contains(itemUseArray.Thieving, item.name) then
   if Shared.contains(itemUseArray.Thieving, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Thieving', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Thieving', type='skill'}))
   end
   end
   --Woodcutting
   --Woodcutting
   if Shared.contains(itemUseArray.Woodcutting, item.name) then
   if Shared.contains(itemUseArray.Woodcutting, item.name) then
     table.insert(useArray, '* '..Icons.Icon({'Woodcutting', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Woodcutting', type='skill'}))
   end
   end
    
    
Line 214: Line 215:
   --Mastery Tokens are tied to 'Mastery'
   --Mastery Tokens are tied to 'Mastery'
   if item.type == 'Token' then
   if item.type == 'Token' then
     table.insert(useArray, '* '..Icons.Icon({'Mastery'}))
     table.insert(useArray, chr..Icons.Icon({'Mastery'}))
   end
   end


Line 223: Line 224:
   local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'Hitpoints Skillcape', 'Defence Skillcape'}
   local ignoreCapes = {'Ranged Skillcape', 'Attack Skillcape', 'Strength Skillcape', 'Hitpoints Skillcape', 'Defence Skillcape'}
   if item.name == 'Max Skillcape' or item.name == 'Aorpheat's Signet Ring' or item.name == 'Cape of Completion' then
   if item.name == 'Max Skillcape' or item.name == 'Aorpheat's Signet Ring' or item.name == 'Cape of Completion' then
     table.insert(useArray, '* All skills')
     table.insert(useArray, chr..'All skills')
   elseif item.name == 'Magic Skillcape' then
   elseif item.name == 'Magic Skillcape' then
     table.insert(useArray, '* '..Icons.Icon({'Magic', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Magic', type='skill'}))
     table.insert(useArray, '* '..Icons.Icon({'Alt. Magic', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Alt. Magic', type='skill'}))
   elseif Shared.contains(item.name, 'Skillcape') and not Shared.contains(ignoreCapes, item.name) then
   elseif Shared.contains(item.name, 'Skillcape') and not Shared.contains(ignoreCapes, item.name) then
     local skillName = Shared.splitString(item.name, ' ')[1]
     local skillName = Shared.splitString(item.name, ' ')[1]
     table.insert(useArray, '* '..Icons.Icon({skillName, type='skill'}))
     table.insert(useArray, chr..Icons.Icon({skillName, type='skill'}))
   end
   end


Line 236: Line 237:
   --Special note for Charge Stone of Rhaelyx
   --Special note for Charge Stone of Rhaelyx
   if item.name == 'Charge Stone of Rhaelyx' then
   if item.name == 'Charge Stone of Rhaelyx' then
     table.insert(useArray, '* Powering '..Icons.Icon({'Crown of Rhaelyx', type='item'}))
     table.insert(useArray, chr..'Powering '..Icons.Icon({'Crown of Rhaelyx', type='item'}))
   end
   end


Line 248: Line 249:
   local item = Items.getItem(itemName)
   local item = Items.getItem(itemName)
   local addCategories = false
   local addCategories = false
  local asList = true
   if frame.args ~= nil then  
   if frame.args ~= nil then  
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
     addCategories = frame.args.addCategories ~= nil and frame.args.addCategories ~= '' and frame.args.addCategories ~= 'false'
    asList = frame.args.addCategories == nil or frame.args.addCategories == '' or frame.args.addCategories == 'true'
   end
   end
   if item == nil then
   if item == nil then
Line 255: Line 258:
   end
   end


   return p._getItemUses(item, addCategories)
   return p._getItemUses(item, asList, addCategories)
end
end