Anonymous

Module:Items/UseTables: Difference between revisions

From Melvor Idle
Update for v0.21
(typing is hard)
(Update for v0.21)
Line 77: Line 77:


   --Before anything else, if this is a potion add it to the appropriate override section
   --Before anything else, if this is a potion add it to the appropriate override section
   if item.herbloreMasteryID ~= nil then
   if item.masteryID ~= nil and item.masteryID[1] == 19 then
     table.insert(itemUseArray[potionUseArray[item.herbloreMasteryID]], item.name)
     table.insert(itemUseArray[potionUseArray[item.masteryID[2]]], item.name)
   end
   end


Line 101: Line 101:
   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, chr..'[[Chest Drop Tables|Can Be Opened]]')  
     table.insert(useArray, chr..'[[Chest Drop Tables|Can Be Opened]]')
  end
 
  -- Check if the item is an entry requirement for any Slayer area
  local isSlayerAreaReq = false
  local slayerAreas = Areas.getAreas(function(area) return area.type == 'slayer' end)
  for i, area in pairs(slayerAreas) do
    if area.entryRequirements ~= nil and type(area.entryRequirements) == 'table' then
      for j, req in pairs(area.entryRequirements) do
        if req.type == "SlayerItem" and req.itemID == item.id then
          isSlayerAreaReq = true
          break
        end
      end
      if isSlayerAreaReq then break end
    end
   end
   end


Line 160: Line 175:
       end
       end
     end
     end
   
 
     if item2.summoningReq ~= nil then
     if item2.summoningReq ~= nil then
       for j, reqSet in pairs(item2.summoningReq) do
       for j, reqSet in pairs(item2.summoningReq) do
Line 175: Line 190:
   --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
 
 
   --Agility
   --Agility
   if canAgile or Shared.contains(itemUseArray.Agility, item.name) then
   if canAgile or Shared.contains(itemUseArray.Agility, item.name) then
Line 193: Line 208:
   end
   end
   --Firemaking
   --Firemaking
   if SkillData.Firemaking[item.id + 1] ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then
   if item.firemakingID ~= nil or Shared.contains(itemUseArray.Firemaking, item.name) then
     table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Firemaking', type='skill'}))
   end
   end
Line 222: Line 237:
   end
   end
   --Slayer
   --Slayer
   if item.slayerCost ~= nil or Shared.contains(itemUseArray.Slayer, item.name) then
   if isSlayerAreaReq or Shared.contains(itemUseArray.Slayer, item.name) then
     table.insert(useArray, chr..Icons.Icon({'Slayer', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Slayer', type='skill'}))
   end
   end
Line 241: Line 256:
     table.insert(useArray, chr..Icons.Icon({'Woodcutting', type='skill'}))
     table.insert(useArray, chr..Icons.Icon({'Woodcutting', type='skill'}))
   end
   end
 
 
   --Other odds and ends:
   --Other odds and ends:


   --Mastery Tokens are tied to 'Mastery'
   --Mastery Tokens are tied to 'Mastery'
   if item.type == 'Token' then
   if item.isToken and item.skill ~= nil then
     table.insert(useArray, chr..Icons.Icon({'Mastery'}))
     table.insert(useArray, chr..Icons.Icon({'Mastery'}))
   end
   end
Line 252: Line 267:
   --Except Max Skillcape, which is tied to all skills. (And so is the Signet Ring)
   --Except Max Skillcape, which is tied to all skills. (And so is the Signet Ring)
   --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', '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 Shared.contains({'Max Skillcape', 'Aorpheat's Signet Ring', 'Cape of Completion'}, item.name) then
     table.insert(useArray, chr..'All skills')
     table.insert(useArray, chr..'All skills')
   elseif item.name == 'Magic Skillcape' then
   elseif item.name == 'Magic Skillcape' then
Line 297: Line 312:
   local addCategories = false
   local addCategories = false
   local asList = true
   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'
     asList = frame.args.addCategories == nil or frame.args.addCategories == '' or frame.args.addCategories == 'true'
Line 385: Line 400:
       for j, req in pairs(item2.herbloreReq) do
       for j, req in pairs(item2.herbloreReq) do
         if req.id == item.id then
         if req.id == item.id then
           local potionData = SkillData.Herblore.ItemData[item2.herbloreMasteryID + 1]
           local potionData = SkillData.Herblore.ItemData[item2.masteryID[2] + 1]
           local mat = item2.herbloreReq
           local mat = item2.herbloreReq
           local xp = potionData.herbloreXP
           local xp = potionData.herbloreXP
Line 408: Line 423:
             mat[k].qty = math.max(math.floor(1000 / math.max(item.sellsFor, 20)), 1)
             mat[k].qty = math.max(math.floor(1000 / math.max(item.sellsFor, 20)), 1)
             local xp = 5 + 2 * math.floor(item2.summoningLevel * 0.2)
             local xp = 5 + 2 * math.floor(item2.summoningLevel * 0.2)
             local rowReq = Icons._SkillReq('Summoning', item2.summoningLevel)
             local rowReq = item2.summoningLevel
             table.insert(useArray, {item = item2, qty = 25, mats = mat, skill = 'Summoning', reqVal = item2.summoningLevel, req = rowReq, xp = xp})
             table.insert(useArray, {item = item2, qty = 25, mats = mat, skill = 'Summoning', req = rowReq, xp = xp})
           end
           end
         end
         end
Line 507: Line 522:
       local matQty = mat.qty ~= nil and mat.qty or mat[2]
       local matQty = mat.qty ~= nil and mat.qty or mat[2]
       local matText = ''
       local matText = ''
     
 
       if i > 1 then result = result..'<br/>' end
       if i > 1 then result = result..'<br/>' end
       if matID >= 0 then
       if matID >= 0 then
Line 569: Line 584:
       table.insert(costArray, Icons.Icon({item.name, type="item", qty=mat[2]}))
       table.insert(costArray, Icons.Icon({item.name, type="item", qty=mat[2]}))
     end
     end
   
 
     result = result..'||'..table.concat(costArray, '<br/>')
     result = result..'||'..table.concat(costArray, '<br/>')