WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Identifying Faction Names? (https://www.wowinterface.com/forums/showthread.php?t=33088)

acapela 06-10-10 07:22 PM

Identifying Faction Names?
 
i am trying to parse faction names out of Blizzard unit tooltips (canonically, the faction of a unit seems to occur right after the unit level, if it exists, and if it does not indicate the unit is flagged for PvP). however, it seems that the default tooltip also includes quest information, and perhaps other things, in that location. so my parsing is identifying "false positives".

i am looking for a way to determine whether a generic string contains a valid faction name. i see the GetFactionInfo() API, and i could cycle through all of that for the factions that the player "knows" about. but i doubt that covers everything.

can anyone suggest another API-oriented approach, or know of a global variable containing localized faction strings, or some such? all i need is a "quick" true/false test (basically a set membership test): does a given string contain a faction name? or, a reliable way to construct such a set.

i rummaged the MPQ lua without success.

thanks in advance.

v6o 06-11-10 12:24 PM

Quote:

Originally Posted by acapela (Post 191677)
i see the GetFactionInfo() API, and i could cycle through all of that for the factions that the player "knows" about. but i doubt that covers everything.

That's the way I've seen people doing so far. Seems far too inefficient for me though so I didn't bother touching it.

Waverian 06-11-10 01:24 PM

I don't see any efficiency problems. You only need to scan when the faction list changes otherwise you just use a cache. In most play sessions this is one iteration of the faction list and a simple hash table lookup when you need the information.

There's a babble library for this though.

http://www.wowace.com/addons/libbabble-faction-3-0/

acapela 06-11-10 09:45 PM

Quote:

Originally Posted by Waverian (Post 191769)
I don't see any efficiency problems. You only need to scan when the faction list changes otherwise you just use a cache. In most play sessions this is one iteration of the faction list and a simple hash table lookup when you need the information.

There's a babble library for this though.

http://www.wowace.com/addons/libbabble-faction-3-0/

yeah, i had planned to cycle through the GetFactionInfo() list, once on addon load, and store names in a table for lookup. my concern is that a list from this source would not be "complete".

libbabble-faction-3.0 would be a good option (though it adds a library dependency, and presumably consumes memory at runtime, etc, though presumably no more than any other comprehensive list of faction names would).

i was hoping Blizzard already had a LUA-accessible list squirreled away in some novel location, but i suppose the existence of libbabble-faction is proof that they do not... anyway, i will try implementing with that.

thanks much for the help.


All times are GMT -6. The time now is 06:23 AM.

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