Anonymous

Module:Sandbox/AuronTest: Difference between revisions

From Melvor Idle
_getItemStat: Don't waste time iterating over equipRequirements if the specified skill was not found
(_getItemStat: Add backwards compatibility for isTwoHanded & LevelRequirement stats)
(_getItemStat: Don't waste time iterating over equipRequirements if the specified skill was not found)
Line 139: Line 139:
     local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$'))
     local skillName = Shared.titleCase(string.match(StatName, '^(.+)LevelRequired$'))
     local skillID = Constants.getSkillID(skillName)
     local skillID = Constants.getSkillID(skillName)
     for i, req in pairs(item.equipRequirements) do
     if skillID ~= nil then
      if req.type == 'Level' then
      for i, req in pairs(item.equipRequirements) do
        for j, levelReq in pairs(req.levels) do
        if req.type == 'Level' then
          if levelReq.skill == skillID then
          for j, levelReq in pairs(req.levels) do
            result = levelReq.level
            if levelReq.skill == skillID then
             break
              result = levelReq.level
              break
             end
           end
           end
          if result ~= nil then break end
         end
         end
        if result ~= nil then break end
       end
       end
     end
     end