Module:CombatAreas: Difference between revisions

p.getAreaStat now handles Slayer areas
(Added getAreaStat)
(p.getAreaStat now handles Slayer areas)
Line 6: Line 6:
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')


function processArea(area, index)
function processArea(area, index)
Line 21: Line 22:
function p.getArea(name)
function p.getArea(name)
   local result = nil
   local result = nil
  mw.log(name)
   --There are three types of areas but the lists are pretty short so looping all of them isn't a real issue
   --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
   for i, area in pairs(AreaData.combatAreas) do
Line 58: Line 58:
     return "ERROR: Could not find an area named "..areaName
     return "ERROR: Could not find an area named "..areaName
   end
   end
  if statName == 'slayerLevel' then
    return Icons._SkillReq('Slayer', area.slayerLevel)
  end
  if statName == 'slayerItem' then
    if area.slayerItem ~= nil and area.slayerItem > 0 then
      local slayItem = Items.getItemByID(area.slayerItem)
      return Icons.Icon({slayItem.name, type='item'})
    else
      return 'None'
    end
  end
   return area[statName]
   return area[statName]
end
end