WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Instance Data Help (https://www.wowinterface.com/forums/showthread.php?t=58031)

Coin_ 05-29-20 03:37 AM

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

Ketho 05-29-20 06:42 AM

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

Coin_ 05-29-20 04:36 PM

This is fantastic, thank you so much for your help.


All times are GMT -6. The time now is 08:19 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI