Thread Tools Display Modes
07/23/14, 02:40 PM   #1
klaro00
 
klaro00's Avatar
Join Date: Apr 2014
Posts: 31
How to detect the player's race

Hi,

I'm about to write an addon which displays the player's Alliance, Race and Class in a tooltip. For each of them I display the localized name plus the respective icon/symbol.

Alliance and Class is not a problem since I get both a localized text and a numeric type value. I use the type to lookup the icon texture in a table.

My problem: I cannot find a way to get the player's race as a numeric type. All I find is function
GetUnitRace("player")
which returns the localized race. This is not really helpful because I cannot use this as an index for a table with race icon textures.

How would I manage to get the race information in a more abstract way (not only as a localized text), or is there a way to get the 64x64 race icon directly?

For illustration of the purpose of my question see attachment.

Regards,
Klaro
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140723_222802.png
Views:	455
Size:	115.2 KB
ID:	357  
  Reply With Quote
07/23/14, 04:17 PM   #2
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by klaro00 View Post
Hi,

I'm about to write an addon which displays the player's Alliance, Race and Class in a tooltip. For each of them I display the localized name plus the respective icon/symbol.

Alliance and Class is not a problem since I get both a localized text and a numeric type value. I use the type to lookup the icon texture in a table.

My problem: I cannot find a way to get the player's race as a numeric type. All I find is function
GetUnitRace("player")
which returns the localized race. This is not really helpful because I cannot use this as an index for a table with race icon textures.

How would I manage to get the race information in a more abstract way (not only as a localized text), or is there a way to get the 64x64 race icon directly?

For illustration of the purpose of my question see attachment.

Regards,
Klaro
AFAIK there is no other function which you can use. You will have to stick with GetUnitRace(unitTag).

You will probably need to make a lookup table such as:
Lua Code:
  1. --   breton = "esoui/art/charactercreate/charactercreate_bretonicon_up.dds",
  2. --   orc = "esoui/art/charactercreate/charactercreate_orcicon_up.dds",
  3. --   redguard = "esoui/art/charactercreate/charactercreate_redguardicon_up.dds",
  4. --   altmer = "esoui/art/charactercreate/charactercreate_altmericon_up.dds",
  5. --   bosmer = "esoui/art/charactercreate/charactercreate_bosmericon_up.dds",
  6. --   kajiit = "esoui/art/charactercreate/charactercreate_khajiiticon_up.dds",
  7. --   argonian = "esoui/art/charactercreate/charactercreate_argonianicon_up.dds",
  8. --   dunmer = "esoui/art/charactercreate/charactercreate_dunmericon_up.dds",
  9. --   nord = "esoui/art/charactercreate/charactercreate_nordicon_up.dds",
  10. --   imperial = "esoui/art/charactercreate/charactercreate_imperialicon_up.dds",
  11.  
  12. local raceTable = {
  13.    ["Breton"] = "breton",
  14.    ["Bretone"] = "breton", --de, male
  15.    ["Bretonin"] = "breton", --de, female
  16.    ["Bréton"] = "breton", --fr, male
  17.    ["Brétonne"] = "breton", --fr, female
  18.    ["Orc"] = "orc",
  19.    ["Ork"] = "orc", --de, male/female
  20.    ["Orque"] = "orc", --fr, male/female
  21.    ["Redguard"] = "redguard",
  22.    ["Rothwardone"] = "redguard", --de, male
  23.    ["Rothwardonin"] = "redguard", --de, female
  24.    ["Rougegarde"] = "redguard", --fr, male/female
  25.    ["High Elf"] = "altmer",
  26.    ["Hochelf"] = "altmer", --de, male
  27.    ["Hochelfin"] = "altmer", --de, female
  28.    ["Haut-Elfe"] = "altmer", --fr, male
  29.    ["Haute-Elfe"] = "altmer", --fr, female
  30.    ["Wood Elf"] = "bosmer",
  31.    ["Waldelf"] = "bosmer", --de, male
  32.    ["Waldelfin"] = "bosmer", --de, female
  33.    ["Elfe des bois"] = "bosmer", --fr, male/female
  34.    ["Khajiit"] = "khajiit",
  35.    ["Argonian"] = "argonian",
  36.    ["Argonier"] = "argonian", --de, male
  37.    ["Argonierin"] = "argonian", --de, female
  38.    ["Argonien"] = "argonian", --fr, male
  39.    ["Argonienne"] = "argonian", --fr, female
  40.    ["Dark Elf"] = "dunmer",
  41.    ["Dunkelelf"] = "dunmer", --de, male
  42.    ["Dunkelelfin"] = "dunmer", --de, female
  43.    ["Elfe Noir"] = "dunmer", --fr, male
  44.    ["Elfe Noire"] = "dunmer", --fr, female
  45.    ["Nord"] = "nord",
  46.    ["Nordique"] = "nord", --fr, male/female
  47.    ["Imperial"] = "imperial",
  48.    ["Kaiserlicher"] = "imperial", --de, male
  49.    ["Kaiserliche"] = "imperial", --de, female
  50.    ["Impérial"] = "imperial", --fr, male
  51.    ["Impériale"] = "imperial", --fr, female
  52. }
  53.  
  54. local race = zo_strformat(SI_RACE_NAME, GetUnitRace("player"))
  55. local raceCode = raceTable[race]
  56. local texture = "esoui/art/charactercreate/charactercreate_" ..  raceCode .. "icon_up.dds"
  57. d(texture)

Last edited by Garkin : 07/23/14 at 05:26 PM. Reason: Added missing quotes (omg, strings really needs quotes? :D)
  Reply With Quote
07/23/14, 04:48 PM   #3
Sephiroth018
 
Sephiroth018's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 20
Originally Posted by Garkin View Post
...best possible solution...
And Garkin saves the day again, thank you.
I was also looking for that functionality, as I want to display item icons for the race of the logged in character in my addon.
  Reply With Quote
07/24/14, 12:21 AM   #4
klaro00
 
klaro00's Avatar
Join Date: Apr 2014
Posts: 31
Yep, thanks you Garkin!!! I was afraid about that this is really the final solution, but at least it's so well prepared so that we do not have to investigate the localized race names.

// Klaro
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » How to detect the player's race


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