View Single Post
05/01/23, 11:11 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
At first: Unit and zone names can end on e.g. ^m or ^p or similar which shows (for non en language) the gender of the text to add the correct article.
So you should first remove those by using lcoal nameClean = zo_strformat(SI_UNIT_NAME, GetUnitName("player")) e.g.

And if you want to check for zones why don't you simply use the zoneIndex, which are language independent "always the same numbers", and thus way easier to check for?

Lua Code:
  1. local myTableToCheck = {
  2.      [zoneIndexOfBalFoyenHere] = true,
  3. }
  4. if myTableToCheck[GetUnitZoneIndex("player")] then
  5.  ---player is in that zone
  6. end


If you need to check that the player is in the zone, even though she/he is in a subzone like a delve, check the other API functions like GetParentZoneId() and so on to maybe get the parent zoneId (should be the top zone's ID then, not the one of the delve anymore). Not sure what your usecase is and what you need to check and get, but string comparison is slow, and error prone. Better use the index and id functions instead as no translation or similar would be needed.

Last edited by Baertram : 05/01/23 at 11:13 AM.
  Reply With Quote