4,951
edits
Falterfire (talk | contribs) (Added getMonsterAttackSpeed) |
Falterfire (talk | contribs) (added pGetMonsterAreas.) |
||
Line 3: | Line 3: | ||
local Constants = mw.loadData('Module:Constants/data') | local Constants = mw.loadData('Module:Constants/data') | ||
local MonsterData = mw.loadData('Module:Monsters/data') | local MonsterData = mw.loadData('Module:Monsters/data') | ||
local AreaData = mw.loadData('Module:CombatAreas/data') | |||
local Shared = require('Module:Shared') | |||
local Icons = require('Module:Icons') | |||
function p.clone(orig) | |||
if type(obj) ~= 'table' then return obj end | |||
local res = {} | |||
for k, v in pairs(obj) do res[clone(k)] = clone(v) end | |||
return res | |||
end | |||
function p.getMonster(name) | function p.getMonster(name) | ||
Line 8: | Line 19: | ||
for i, monster in pairs(MonsterData) do | for i, monster in pairs(MonsterData) do | ||
if(monster.name == name) then | if(monster.name == name) then | ||
result = monster | result = Shared.clone(monster) | ||
--Make sure every monster has an ID, and account for the 1-based indexing of Lua | |||
result.id = i - 1 | |||
end | end | ||
end | end | ||
Line 116: | Line 129: | ||
end | end | ||
return effDefLvl * defBonus | return effDefLvl * defBonus | ||
end | |||
function p.getMonsterAreas(frame) | |||
local MonsterName = frame.args ~= nil and frame.args[1] or frame | |||
local monster = p.getMonster(MonsterName) | |||
if monster == nil then | |||
return "ERROR: No monster with name "..monsterName.." found" | |||
end | |||
local result = '' | |||
for i, area in pairs(AreaData.combatAreas) do | |||
if Shared.contains(area.monsters, monster.id) then | |||
if string.len(result) > 0 then result = result..'<br/>' end | |||
result = result..Icons.Icon({area.areaName, type = 'combatArea'}) | |||
end | |||
end | |||
for i, area in pairs(AreaData.slayerAreas) do | |||
if Shared.contains(area.monsters, monster.id) then | |||
if string.len(result) > 0 then result = result..'<br/>' end | |||
result = result..Icons.Icon({area.areaName, type = 'combatArea'}) | |||
end | |||
end | |||
for i, area in pairs(AreaData.dungeons) do | |||
if Shared.contains(area.monsters, monster.id) then | |||
if string.len(result) > 0 then result = result..'<br/>' end | |||
result = result..Icons.Icon({area.name, type = 'dungeon'}) | |||
end | |||
end | |||
return result | |||
end | end | ||
return p | return p |