Module:Items/UseTables: Difference between revisions

Fixed issue with upgradeable items not listing if they were costs for other things
m (_getItemUseTable: Replace hard-coded Summoning GP/SC cost value with in-game data)
(Fixed issue with upgradeable items not listing if they were costs for other things)
Line 112: Line 112:
   local canAgile = false
   local canAgile = false
   local canSummon = false
   local canSummon = false
   if item.trimmedItemID ~= nil then
 
    canUpgrade = true
   canUpgrade = true
   else
 
    for i, item2 in pairs(ItemData.Items) do
   for i, item2 in pairs(ItemData.Items) do
      if item2.itemsRequired ~= nil then
    if item2.itemsRequired ~= nil then
        for j, req in pairs(item2.itemsRequired) do
      for j, req in pairs(item2.itemsRequired) do
          if req[1] == item.id then
        if req[1] == item.id then
            canUpgrade = true
          canUpgrade = true
            break
          break
          end
         end
         end
       end
       end
    end


      if item2.craftReq ~= nil then
    if item2.craftReq ~= nil then
        for j, req in pairs(item2.craftReq) do
      for j, req in pairs(item2.craftReq) do
          if req.id == item.id then
        if req.id == item.id then
            canCraft = true
          canCraft = true
            break
          break
           end
        end
      end
    end
    if item2.fletchReq ~= nil then
      for j, req in pairs(item2.fletchReq) do
        if req.id == item.id then
           canFletch = true
          break
         end
         end
       end
       end
 
    end
      if item2.fletchReq ~= nil then
    if item2.runecraftReq ~= nil then
        for j, req in pairs(item2.fletchReq) do
      for j, req in pairs(item2.runecraftReq) do
          if req.id == item.id then
        if req.id == item.id then
            canFletch = true
          canRunecraft = true
            break
          break
          end
         end
         end
       end
       end
    end


      if item2.runecraftReq ~= nil then
    if item2.herbloreReq ~= nil then
        for j, req in pairs(item2.runecraftReq) do
      for j, req in pairs(item2.herbloreReq) do
          if req.id == item.id then
        if req.id == item.id then
            canRunecraft = true
          canHerblore = true
            break
          break
          end
         end
         end
       end
       end
 
    end
      if item2.herbloreReq ~= nil then
   
        for j, req in pairs(item2.herbloreReq) do
    if item2.summoningReq ~= nil then
      for j, reqSet in pairs(item2.summoningReq) do
        for k, req in pairs(reqSet) do
           if req.id == item.id then
           if req.id == item.id then
             canHerblore = true
             canSummon = true
             break
             break
          end
        end
      end
     
      if item2.summoningReq ~= nil then
        for j, reqSet in pairs(item2.summoningReq) do
          for k, req in pairs(reqSet) do
            if req.id == item.id then
              canSummon = true
              break
            end
           end
           end
         end
         end
Line 173: Line 170:
     end
     end
   end
   end
   --Check if Agility applies here
   --Check if Agility applies here
   canAgile = Shared.tableCount(Agility.getObstaclesForItem(item.id)) > 0
   canAgile = Shared.tableCount(Agility.getObstaclesForItem(item.id)) > 0
  if canUpgrade then
    if item.canUpgrade or (item.type == 'Armour' and item.canUpgrade == nil) then
      table.insert(categoryArray, '[[Category:Upgradeable Items]]')
    end
    table.insert(useArray, chr..'[[Upgrading Items]]')
  end
    
    
   --Agility
   --Agility
Line 285: Line 276:
   if Shared.tableCount(shopArray) > 0 then
   if Shared.tableCount(shopArray) > 0 then
     table.insert(useArray, chr..Icons.Icon({'Shop'}))
     table.insert(useArray, chr..Icons.Icon({'Shop'}))
  end
  if canUpgrade then
    if item.canUpgrade or (item.type == 'Armour' and item.canUpgrade == nil) then
      table.insert(categoryArray, '[[Category:Upgradeable Items]]')
    end
    table.insert(useArray, chr..'[[Upgrading Items]]')
   end
   end