4,951
edits
Falterfire (talk | contribs) (Added p.getMonsterAreas) |
Falterfire (talk | contribs) (Some tweaks to make handling areas in other code easier) |
||
Line 7: | Line 7: | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
function processArea(area, index) | |||
local result = Shared.clone(area) | |||
result.id = index - 1 | |||
if result.name == nil then | |||
result.name = result.areaName | |||
end | |||
if Shared.contains(result.type, 'Dungeon') then | |||
result.type = 'dungeon' | |||
end | |||
return result | |||
end | |||
function p.getArea(name) | function p.getArea(name) | ||
Line 14: | Line 26: | ||
for i, area in pairs(AreaData.combatAreas) do | for i, area in pairs(AreaData.combatAreas) do | ||
if area.areaName == name then | if area.areaName == name then | ||
return processArea(area, i) | |||
end | end | ||
end | end | ||
Line 22: | Line 32: | ||
for i, area in pairs(AreaData.slayerAreas) do | for i, area in pairs(AreaData.slayerAreas) do | ||
if area.areaName == name then | if area.areaName == name then | ||
return processArea(area, i) | |||
end | end | ||
end | end | ||
Line 30: | Line 38: | ||
for i, area in pairs(AreaData.dungeons) do | for i, area in pairs(AreaData.dungeons) do | ||
if area.name == name then | if area.name == name then | ||
return processArea(area, i) | |||
end | end | ||
end | end | ||
Line 45: | Line 50: | ||
for i, area in pairs(AreaData.combatAreas) do | for i, area in pairs(AreaData.combatAreas) do | ||
if Shared.contains(area.monsters, monsterID) then | if Shared.contains(area.monsters, monsterID) then | ||
table.insert(areaArray, processArea(area, i)) | |||
table.insert(areaArray, | |||
end | end | ||
end | end | ||
Line 53: | Line 56: | ||
for i, area in pairs(AreaData.slayerAreas) do | for i, area in pairs(AreaData.slayerAreas) do | ||
if Shared.contains(area.monsters, monsterID) then | if Shared.contains(area.monsters, monsterID) then | ||
table.insert(areaArray, processArea(area, i)) | |||
table.insert(areaArray, | |||
end | end | ||
end | end | ||
Line 61: | Line 62: | ||
for i, area in pairs(AreaData.dungeons) do | for i, area in pairs(AreaData.dungeons) do | ||
if Shared.contains(area.monsters, monsterID) then | if Shared.contains(area.monsters, monsterID) then | ||
table.insert(areaArray, processArea(area, i)) | |||
table.insert(areaArray, | |||
end | end | ||
end | end |