Thread Tools Display Modes
08-15-06, 01:07 AM   #1
Jayhawk
Premium Member
 
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
How to tell Horde or Alliance?

This may have been asked before, but I tried finding it, and drew a blank...

What I'd like to know is what function to call to figure out if a character you play is Horde or Alliance. Basically, I'm saving skill information, but don't think it's very useful showing the skills for Alliance chars when playing a Horde char on the same server, so I'd like to differentiate between the two of them.

Assistance would be appreciated.
  Reply With Quote
08-15-06, 01:34 AM   #2
neolith
A Fallenroot Satyr
 
neolith's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 22
I think you have to make use of UnitRace("unit") and check for raceEN.
__________________
- The biggest trick the devil ever pulled was convincing the world he didn't exist. -
  Reply With Quote
08-15-06, 11:12 AM   #3
Esamynn
Featured Artist
Premium Member
Featured
Join Date: Jan 2005
Posts: 395
Check out http://www.wowwiki.com/API_UnitFactionGroup
  Reply With Quote
08-15-06, 12:43 PM   #4
ckknight
A Warpwood Thunder Caller
 
ckknight's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 90
Fun facts:

UnitFactionGroup("player") is available only after PLAYER_LOGIN, whereas
UnitRace("player") is always available.

So if you need to check your own faction at the beginning, you'd have to check:

local _,race = UnitRace("player")
local faction = (race == "TAUREN" or race == "ORC" or race == "TROLL" or race == "SCOURGE") and FACTION_HORDE or FACTION_ALLIANCE
  Reply With Quote
08-19-06, 03:46 AM   #5
Jayhawk
Premium Member
 
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
Thanks for the tips. I haven't quite managed to get things working, but... I'll keep you posted.
  Reply With Quote
08-28-06, 03:18 AM   #6
Jayhawk
Premium Member
 
Jayhawk's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 105
It looks like I managed to get this to work. So thanks for all the help.

I was suprised though that:

local faction = (UnitRace("player") == "TAUREN" or race == "ORC" or race == "TROLL" or race == "SCOURGE") and FACTION_HORDE or FACTION_ALLIANCE

Doesn't seem to work. Must be my being new to LUA, is can anyone willing to explain to me why it doesnt'work?
  Reply With Quote
08-28-06, 05:15 AM   #7
wereHamster
A Black Drake
 
wereHamster's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 80
Originally Posted by Jayhawk
local faction = (UnitRace("player") == "TAUREN" or race == "ORC" or race == "TROLL" or race == "SCOURGE") and FACTION_HORDE or FACTION_ALLIANCE
The first return value is the localized name, the second the uppercase english name. That's why ckknight did:
Code:
local _, race = UnitRace("player")
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to tell Horde or Alliance?

Thread Tools
Display Modes

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