WoW:API TargetUnit: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
m (Move page script moved page API TargetUnit to API TargetUnit without leaving a redirect)
 
(8 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<center>'''TargetUnit''' ''-Documentation by danboo-''</center>
{{wowapi}} __NOTOC__
 
{{protectedapi|2.0.1|For alternatives, try [[API_SecureTemplates|Secure Templates]] or /target [unitID].}}
Selects the specified id as the current target.  
Selects the specified id as the current target.  


  TargetUnit(id);
  TargetUnit("unit");
 
----
;''Arguments''


:(String id)
== Parameters ==
=== Arguments ===
:("unit")


:;id : the identifier of the target to select
:;unit : String - The [[unitId]] to select as a target.


----
=== Returns ===
;''Returns''


:;nil
:;nil


----
== Example ==
;''Example''
TargetUnit("player");


;''Result''
:When the player changes his target there is a small delay before the global variable 'playertarget' is updated. This can be exploited and used for restoring your old target.


----
TargetUnit("unit")
;''Description''
CastSpell()<br>
TargetUnit("playertarget")


: Selects the specified id as the current target. The id can be any of <tt>"player"</tt>, <tt>"party1"</tt>, <tt>"party2"</tt>, <tt>"party3"</tt> or <tt>"party4"</tt>.
=== Result ===


: The id <tt>"player"</tt> refers to the character in use, while the <tt>"party*"</tt> ids refer to the corresponding party members.
: This will restore your old target because of the delay. It will not clear your target if you didnt have one.


: <tt>"pet"</tt> should work to, and will (if it works) target the players pet --[[User:Sarf|Sarf]]
== Details ==


{{Template:WoW API}}
: Selects the specified id as the current target. One can use any of the defined [[unitId]] values.

Latest revision as of 04:47, 15 August 2023

WoW API < TargetUnit

Selects the specified id as the current target.

TargetUnit("unit");

Parameters[edit]

Arguments[edit]

("unit")
unit
String - The unitId to select as a target.

Returns[edit]

nil

Example[edit]

When the player changes his target there is a small delay before the global variable 'playertarget' is updated. This can be exploited and used for restoring your old target.
TargetUnit("unit")
CastSpell()
TargetUnit("playertarget")

Result[edit]

This will restore your old target because of the delay. It will not clear your target if you didnt have one.

Details[edit]

Selects the specified id as the current target. One can use any of the defined unitId values.