Thread Tools Display Modes
10-05-11, 01:31 AM   #1
Lysiander
An Aku'mai Servant
Join Date: Dec 2007
Posts: 37
Reliable Instance name function & delaying a function call

Hello there,

I'm working on my oUF layout and am currently immersed in building a Raid Debuff functionality. It all works fine so far, but I have two problems.

1. I have a table, containing the debuffs to show set up as containing keys with zone names and subtables with IDs and priority values as values to the zone names. I have trie to use the GetInstanceInfo() function to compare instance names, but it seems to return localized names. Even when I run the function ingame via chat, inputting the name it returns in the table doesn't work. GetRealZoneText does work, but seems to be unreliable for some reason. Is there a function to return a non localized zone name? I like the option of filtering by difficulty as well as zone that GetInstanceInfo provides, so I would love to get that one to work.

2. I have linked the Debuff Check function call to the UNIT_AURA event. Since that fires pretty often I want to minimize the number of auras it has to check for. Because of this I am dynamically populating the table based on the PLAYER_ENTERING_WORLD event. This works fine so far when I change zones, but does not when I reload the UI. I suspect that this is because during the reload the game does not get usable information from the GetRealZoneText function and hence simply creates an empty table. So i am wondering wether there is a way to delay the function call for a short while. Alternatively, is there an event that would be better suited for my purposes than the PLAYER_ENTERING_WORLD one?

Thanks for your time and help.
  Reply With Quote
10-05-11, 01:33 AM   #2
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
This is why libBabbleZone was created Another method would be to use the GetCurrentMapAreaID() function, but not sure what numbers it returns in a dungeon.

For events, you could use a timer, or an old trick I use is to register UPDATE_PENDING_MAIL, as it fires pretty late. Just make sure to unregister it after it first fires.

Last edited by Nibelheim : 10-05-11 at 01:37 AM.
  Reply With Quote
10-05-11, 02:51 AM   #3
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Have you tried GetMapInfo()? This returns the filename for the map used. Most dungeons have maps now.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-05-11, 02:52 AM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by SDPhantom View Post
Have you tried GetMapInfo()? This returns the filename for the map used. Most dungeons have maps now.
Ohhh, handy
  Reply With Quote
10-05-11, 03:36 AM   #5
Lysiander
An Aku'mai Servant
Join Date: Dec 2007
Posts: 37
Thanks for the replies.
I would like to avoid libs, as I am not really comfortable in Lua (or programming in general) and want to keep things as simple as possible. I will try to hook the UPDATE_PENDING_MAIL event and see how that turns out.

GetMapInfo() sounds interesting, but how does that work for multilevel dungeons? Does it return a unique name on a per dungeon or per level basis?

Edit: It seems to be unique. I just ran through Sethekk Halls, which has two map levels and it returned "SethekkHalls" on both. I'll test a few more, but it looks like this could solve the map name issue.

Last edited by Lysiander : 10-05-11 at 03:47 AM.
  Reply With Quote
10-05-11, 05:08 AM   #6
Lysiander
An Aku'mai Servant
Join Date: Dec 2007
Posts: 37
Allright, UPDATE_PENDING_MAIL does fire late enough for my purposes. However, I am unsure how to unregister the event. Basically, so far my code looks like this:

Code:
lib.gen_raidDebuffs = function(f)

<codeblock>

f:RegisterEvent("WORLD_MAP_UPDATE", ns.populateTable)
f:RegisterEvent("UPDATE_PENDING_MAIL", ns.populateTable)
f:UnregisterEvent("UPDATE_PENDING_MAIL")
The lib.gen_raidDebuffs function is, as far as I know, only called when the UnitFrames are build by oUF, that is whenever the addons are loaded. The above seems to work fine, but I was wondering if there is any way to test wether the event is actually unregistered.
  Reply With Quote
10-05-11, 10:03 AM   #7
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by Lysiander View Post
GetMapInfo() sounds interesting, but how does that work for multilevel dungeons? Does it return a unique name on a per dungeon or per level basis?

Edit: It seems to be unique. I just ran through Sethekk Halls, which has two map levels and it returned "SethekkHalls" on both. I'll test a few more, but it looks like this could solve the map name issue.
Here's a clip of the code used in WorldMapFrame_Update(). Note this function will return nil for both "World" and "Cosmic" maps. "Cosmic" is the map where you select either to view Outland or Azeroth. "World" is all 4 continents on Azeroth.

lua Code:
  1. local mapFileName, textureHeight = GetMapInfo();
  2. if ( not mapFileName ) then
  3.     if ( GetCurrentMapContinent() == WORLDMAP_COSMIC_ID ) then
  4.         mapFileName = "Cosmic";
  5.         OutlandButton:Show();
  6.         AzerothButton:Show();
  7.     else
  8.         -- Temporary Hack (Temporary meaning 6 yrs, haha)
  9.         mapFileName = "World";
  10.         OutlandButton:Hide();
  11.         AzerothButton:Hide();
  12.     end
  13.     DeepholmButton:Hide();
  14.     KezanButton:Hide();
  15.     LostIslesButton:Hide();
  16.     TheMaelstromButton:Hide();
  17. else
  18.     OutlandButton:Hide();
  19.     AzerothButton:Hide();
  20.     if ( GetCurrentMapContinent() == WORLDMAP_MAELSTROM_ID and GetCurrentMapZone() == 0 ) then
  21.         DeepholmButton:Show();
  22.         KezanButton:Show();
  23.         LostIslesButton:Show();
  24.         TheMaelstromButton:Show();
  25.     else
  26.         DeepholmButton:Hide();
  27.         KezanButton:Hide();
  28.         LostIslesButton:Hide();
  29.         TheMaelstromButton:Hide();
  30.     end
  31. end
  32.  
  33. local texName;
  34. local dungeonLevel = GetCurrentMapDungeonLevel();
  35. if (DungeonUsesTerrainMap()) then
  36.     dungeonLevel = dungeonLevel - 1;
  37. end
  38. local completeMapFileName;
  39. if ( dungeonLevel > 0 ) then
  40.     completeMapFileName = mapFileName..dungeonLevel.."_";
  41. else
  42.     completeMapFileName = mapFileName;
  43. end
  44. local numOfDetailTiles = GetNumberOfDetailTiles();
  45. for i=1, numOfDetailTiles do
  46.     texName = "Interface\\WorldMap\\"..mapFileName.."\\"..completeMapFileName..i;
  47.     _G["WorldMapDetailTile"..i]:SetTexture(texName);
  48. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-05-11, 11:20 AM   #8
Lysiander
An Aku'mai Servant
Join Date: Dec 2007
Posts: 37
If I understand that code snipped correctly, the name returned by GetMapInfo() is always the same and the game determines multilevel maps by calling GetMapInfo and adding the number of the map to the value returned by GetMapInfo(). So a short answer to my question would be: "Yes´, the name returned by GetMapInfo() is unique to the zone and not the level of the zone." Correct?

P.S. Temorary meaning 6 years... . Nice
  Reply With Quote
10-05-11, 05:15 PM   #9
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
To unregister the event, unregister it in the ns.populateTable function, this way it will fire at least once.
  Reply With Quote
10-05-11, 08:47 PM   #10
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by Lysiander View Post
So a short answer to my question would be: "Yes´, the name returned by GetMapInfo() is unique to the zone and not the level of the zone." Correct?
Yep, although I find posting code in use affirms the understanding of what it does.

Originally Posted by Lysiander View Post
P.S. Temorary meaning 6 years... . Nice
I didn't put that in, that comment really is in the function code, lol
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-06-11, 02:46 AM   #11
Lysiander
An Aku'mai Servant
Join Date: Dec 2007
Posts: 37
To unregister the event, unregister it in the ns.populateTable function, this way it will fire at least once.
It seems to fire and unregister as planned the way I have it now, but should I run into trouble (Ill test it with some mailing later) I will do that. thanks.

Yep, although I find posting code in use affirms the understanding of what it does.
I agree, though it can be infuriating at times if you can't decipher what the code means.

As for the comment, I figured that was a blizzard comment. Their programmers have a sense of humor.

Thanks for the help you two.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Reliable Instance name function & delaying a function call


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