WoW:UnitId: Difference between revisions
m (Removed " or <tt>"NPC"</tt>" since tokens are not case sensitive. Added "Others" section. Added stuff under "player".) |
|||
Line 32: | Line 32: | ||
; <tt>"npc"</tt> : The NPC with which the player is currently interacting. | ; <tt>"npc"</tt> : The NPC with which the player is currently interacting. | ||
You can also use the name of a party or raid member as a unit ID: | |||
; <tt>"''name''"</tt> : This must be spelled exactly and will be invalid if the named player is not a part of your party or raid. | |||
== Targets == | == Targets == | ||
You can append the suffix <tt>target</tt> to any UnitId to get a UnitId which refers to that unit's target (e.g. <tt>"partypet2target"</tt>). This appending can be repeated indefinitely (e.g. <tt>"playertargettarget"</tt>), though you will observe an attendant performance hit if you overdo it, as the game engine has to jump from target to target. | You can append the suffix <tt>target</tt> to any UnitId to get a UnitId which refers to that unit's target (e.g. <tt>"partypet2target"</tt>). This appending can be repeated indefinitely (e.g. <tt>"playertargettarget"</tt>), though you will observe an attendant performance hit if you overdo it, as the game engine has to jump from target to target. | ||
If you are using a party or raid member's name as a unit, you need to use hyphens to separate the target chain (e.g. <tt>"Cogwheel-target-target"</tt>). | |||
== Notes == | == Notes == |
Revision as of 21:20, 16 October 2007
Many of the API functions which act on units in the game world (Players, NPC's, Monsters, etc) refer to the unit in question by an identifier that is related to how the player is accessing the unit. The following values are available (they are not case sensitive):
Base Values
- "focus"
- The current player's focus target as selected by the /focus command. (Added in 2.0.0)
- "player"
- The current player.
- It appears that you can also use the current player's proper name in place of "player" (e.g. "Treader"). Although; it seems a little unnecessary since "player" requires no effort from the Lua engine. Plus getting the current player's proper name involves passing "player" to UnitName(), so you might as well just pass "player" to whichever function you are calling.
- "pet"
- The current player's pet
- "partyN"
- The Nth party member excluding the player (1,2,3 or 4)
- "partypetN"
- The pet of the Nth party member (N is 1,2,3, or 4) (Added in 1.5.0)
- "raidN"
- The raid member with raidIndex N (1,2,3,...,40).
- "raidpetN"
- The pet of the raid member with raidIndex N (1,2,3,...,40) (Added in 1.5.0)
- "target"
- The currently targetted unit. May be overriden in macros by unit specified as a value of respective Secure Button attribute.
- "playertarget"
- The currently targetted unit. Always.
- "mouseover"
- The unit which the mouse is currently (or was most recently) hovering over
- "none"
- A valid unit token that always refers to no unit.
Others
The following value also appears in some very specific places (Vendor interactions, for example) or functions.
- "npc"
- The NPC with which the player is currently interacting.
You can also use the name of a party or raid member as a unit ID:
- "name"
- This must be spelled exactly and will be invalid if the named player is not a part of your party or raid.
Targets
You can append the suffix target to any UnitId to get a UnitId which refers to that unit's target (e.g. "partypet2target"). This appending can be repeated indefinitely (e.g. "playertargettarget"), though you will observe an attendant performance hit if you overdo it, as the game engine has to jump from target to target.
If you are using a party or raid member's name as a unit, you need to use hyphens to separate the target chain (e.g. "Cogwheel-target-target").
Notes
Many of the functions which take a UnitId only provide useful results for a subset of ID's. Other functions will only provide information for friendly targets (or those upon which a power is active).
Also, some functions return different values if the target is close enough to be 'visible' to your client (not necessarily in line of sight), as can be determined with UnitIsVisible("unit"), versus further away.