WoW:API UnitSex: Difference between revisions
Jump to navigation
Jump to search
m (Move page script moved page API UnitSex to API UnitSex without leaving a redirect) |
|||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{wowapi}} | |||
Returns the gender of the specified unit. | Returns the gender of the specified unit. | ||
gender_code = UnitSex("unit") | gender_code = UnitSex("unit") | ||
== Arguments == | == Parameters == | ||
=== Arguments === | |||
:("unit") | :("unit") | ||
;unit : String -- The [[API TYPE UnitId|UnitId]] to query (e.g. "player", "party2", "pet", "target" etc.) | |||
== Returns == | === Returns === | ||
:gender_code | :gender_code | ||
;gender_code : Number: | |||
:* 1 = Neutrum / Unknown | |||
:* 2 = Male | |||
:* 3 = Female | |||
== Example == | |||
local genderTable = { "neuter or unknown", "male", "female" }; | |||
DEFAULT_CHAT_FRAME:AddMessage('Target is ' .. genderTable[UnitSex("target")] .. '.'); | |||
==== Result ==== | ==== Result ==== | ||
Target is female. | Target is female. | ||
== Details == | == Details == | ||
* UnitSex("target") will return 1 (neuter/unknown) on "sheeped" mobs, no matter their "true" gender. <small>(Needs reverification after 1.11)</small>. UnitSex("player") does not return 1 on "penguinification". | |||
* Prior to v1.11, the codes were 0=male, 1=female, 2=unknown. | |||
== Notes == | |||
* If "unit" doesn't exist (e.g. UnitSex("target") when you have no target), UnitSex() will return 0.<br/> Previously, it would return 2. (As seen on [[Talk:World of Warcraft API#API_UnitSex.28.22target.22.29_:_What_if_there_is_no_selected_target_.3F|Talk:World of Warcraft API]]) |
Latest revision as of 04:47, 15 August 2023
Returns the gender of the specified unit.
gender_code = UnitSex("unit")
Parameters[edit]
Arguments[edit]
- ("unit")
- unit
- String -- The UnitId to query (e.g. "player", "party2", "pet", "target" etc.)
Returns[edit]
- gender_code
- gender_code
- Number:
- 1 = Neutrum / Unknown
- 2 = Male
- 3 = Female
Example[edit]
local genderTable = { "neuter or unknown", "male", "female" }; DEFAULT_CHAT_FRAME:AddMessage('Target is ' .. genderTable[UnitSex("target")] .. '.');
Result[edit]
Target is female.
Details[edit]
- UnitSex("target") will return 1 (neuter/unknown) on "sheeped" mobs, no matter their "true" gender. (Needs reverification after 1.11). UnitSex("player") does not return 1 on "penguinification".
- Prior to v1.11, the codes were 0=male, 1=female, 2=unknown.
Notes[edit]
- If "unit" doesn't exist (e.g. UnitSex("target") when you have no target), UnitSex() will return 0.
Previously, it would return 2. (As seen on Talk:World of Warcraft API)