17,105
edits
(_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 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 = | for _, key in ipairs(areaDataKeys) do | ||
local areas = GameData.getEntities(key, function(area) return area.pet ~= nil end) | |||
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 = | 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]]' |