Thread Tools Display Modes
05-29-20, 03:37 AM   #1
Coin_
A Defias Bandit
Join Date: May 2020
Posts: 2
Instance Data Help

Hi guys,

I am completely new to the forums and only started looking at WoW addon development yesterday. Apologies if this post is in the wrong place.

Lua is new to me but I am familiar with other programming languages.

Ultimately, I am trying to develop an addon that does the following:
* Detects when the player enters a new zone, discovers what raids/dungeons are in that zone and (eventually) display a window that tells the player what uncollected transmog there is to farm in the those dungeons/raids.

So far I've just been getting familiar with the WoW API by printing stuff out from /reload - not going near UI yet.

I've been using this API reference: https://wowwiki.fandom.com/wiki/World_of_Warcraft_API

I can print out details about raids that the player is currently locked into but I'm struggling to find useful functions that provide info about the raids/zones.

Any pointers?

Thanks
  Reply With Quote
05-29-20, 06:42 AM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
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:
  1. local dungeons = {
  2.     [225] = true, -- The Stockade
  3.     [291] = true, -- The Deadmines
  4. }
  5.  
  6. local function OnEvent(self, event)
  7.     -- entered new zone
  8.     local uiMapId = C_Map.GetBestMapForUnit("player")
  9.     local children = C_Map.GetMapChildrenInfo(uiMapId)
  10.     for _, childMap in pairs(children) do
  11.         if dungeons[childMap.mapID] then
  12.             -- there is a raid/dungeon in this zone
  13.             local zoneName = C_Map.GetMapInfo(uiMapId).name
  14.             print(format("You entered %s (%d) which has %s (%d)", zoneName, uiMapId, childMap.name, childMap.mapID))
  15.         end
  16.     end
  17. end
  18.  
  19. local f = CreateFrame("Frame")
  20. f:RegisterEvent("ZONE_CHANGED_NEW_AREA")
  21. 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

Last edited by Ketho : 05-29-20 at 06:34 PM.
  Reply With Quote
05-29-20, 04:36 PM   #3
Coin_
A Defias Bandit
Join Date: May 2020
Posts: 2
This is fantastic, thank you so much for your help.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Instance Data Help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off