Module:CombatAreas: Difference between revisions

Added p.getMonsterAreas
(fixed a typo)
(Added p.getMonsterAreas)
Line 38: Line 38:


   return nil
   return nil
end
function p.getMonsterAreas(monsterID)
  local areaArray = {}
  --There are three types of areas but the lists are pretty short so looping all of them isn't a real issue
  for i, area in pairs(AreaData.combatAreas) do
    if Shared.contains(area.monsters, monsterID) then
      result = Shared.clone(area)
      result.id = i - 1
      table.insert(areaArray, result)
    end
  end
  for i, area in pairs(AreaData.slayerAreas) do
    if Shared.contains(area.monsters, monsterID) then
      result = Shared.clone(area)
      result.id = i - 1
      table.insert(areaArray, result)
    end
  end
  for i, area in pairs(AreaData.dungeons) do
    if Shared.contains(area.monsters, monsterID) then
      result = Shared.clone(area)
      result.type = 'dungeon'
      result.id = i - 1
      table.insert(areaArray, result)
    end
  end
  return areaArray
end
end