WoW:API TargetUnit: Difference between revisions

(added <tt> formatting to id strings)
 
m (Move page script moved page API TargetUnit to API TargetUnit without leaving a redirect)
 
(9 intermediate revisions by 8 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");


----
== Parameters ==
;''Arguments''
=== Arguments ===
:("unit")


:(String id)
:;unit : String - The [[unitId]] to select as a target.


:;id : the identifier of the target to select
=== Returns ===


----
:;nil
;''Returns''


:;nil
== Example ==


----
: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.
;''Example''
TargetUnit("player");


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


----
=== Result ===
;''Description''


: 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>.  
: This will restore your old target because of the delay. It will not clear your target if you didnt have one.


: The id <tt>"player"</tt> refers to the character in use, while the <tt>"party*"</tt> ids refer to the corresponding party members.
== 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

Arguments

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

Returns

nil

Example

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

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

Details

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