WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   How to tell Horde or Alliance? (https://www.wowinterface.com/forums/showthread.php?t=5785)

Jayhawk 08-15-06 01:07 AM

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. :)

neolith 08-15-06 01:34 AM

I think you have to make use of UnitRace("unit") and check for raceEN.

Esamynn 08-15-06 11:12 AM

Check out http://www.wowwiki.com/API_UnitFactionGroup

ckknight 08-15-06 12:43 PM

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

Jayhawk 08-19-06 03:46 AM

Thanks for the tips. I haven't quite managed to get things working, but... I'll keep you posted. :)

Jayhawk 08-28-06 03:18 AM

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?

wereHamster 08-28-06 05:15 AM

Quote:

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")


All times are GMT -6. The time now is 10:29 PM.

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