Module:Pets: Difference between revisions

Remove dependency on Module:CombatAreas so we can use in Module:Shop
(_getPetChance: Improve grammar)
(Remove dependency on Module:CombatAreas so we can use in Module:Shop)
Line 7: Line 7:
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Areas = require('Module:CombatAreas')


local areaDataKeys = { 'combatAreas', 'dungeons', 'slayerAreas' }
-- Compute combat pet sources once for use later
-- Compute combat pet sources once for use later
local function getCombatPetSources()
local function getCombatPetSources()
local result = {}
local result = {}
local areas = Areas.getAreas(function(area) return area.pet ~= nil end)
for _, key in ipairs(areaDataKeys) do
for i, area in ipairs(areas) do
local areas = GameData.getEntities(key, function(area) return area.pet ~= nil end)
result[area.pet.petID] = { id = area.id, name = area.name, type = area.type, weight = area.pet.weight }
for i, area in ipairs(areas) do
result[area.pet.petID] = { id = area.id, name = area.name, type = area.type, weight = area.pet.weight }
end
end
end
return result
return result
Line 207: Line 209:
function p.getDungeonBoxPetText(frame)
function p.getDungeonBoxPetText(frame)
local dungeonName = frame.args ~= nil and frame.args[1] or frame
local dungeonName = frame.args ~= nil and frame.args[1] or frame
local dung = Areas.getArea(dungeonName)
local dung = nil
for i, key in ipairs(areaDataKeys) do
dung = GameData.getEntityByName(key, dungeonName)
if dung ~= nil then
break
end
end
if dung == nil then
if dung == nil then
return 'ERROR: Invalid dungeon name '..dungeonName..'[[Category:Pages with script errors]]'
return 'ERROR: Invalid dungeon name '..dungeonName..'[[Category:Pages with script errors]]'