You can register for
ZONE_CHANGED_NEW_AREA and check the zone
mapID by looking if the child mapIDs match any of your dungeon mapIDs
Otherwise you could hardcode a list of zones and their respective dungeons
Lua Code:
local dungeons = {
[225] = true, -- The Stockade
[291] = true, -- The Deadmines
}
local function OnEvent(self, event)
-- entered new zone
local uiMapId = C_Map.GetBestMapForUnit("player")
local children = C_Map.GetMapChildrenInfo(uiMapId)
for _, childMap in pairs(children) do
if dungeons[childMap.mapID] then
-- there is a raid/dungeon in this zone
local zoneName = C_Map.GetMapInfo(uiMapId).name
print(format("You entered %s (%d) which has %s (%d)", zoneName, uiMapId, childMap.name, childMap.mapID))
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
f:SetScript("OnEvent", OnEvent)
Code:
> You entered Westfall (52) which has The Deadmines (291)
Other API you might want to look into:
You can also reference
AllTheThings source code for their approach