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)
 
(4 intermediate revisions by 3 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("unit");
  TargetUnit("unit");


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


:;unit : String - The [[API TYPE UnitId|UnitId]] to select as a target.
:;unit : String - The [[unitId]] to select as a target.


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


:;nil
:;nil


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


: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.
: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("unit")
 
CastSpell()<br>
:TargetUnit("unit")<br>
TargetUnit("playertarget")  
:CastSpell()<br>
:TargetUnit("playertarget") -- This will restore your old target because of the delay. It will not clear your target if you didnt have one.
 
;''Result''


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


: Selects the specified id as the current target. One can use any of the defined [[API TYPE UnitId|UnitId]] values. One can also use the [[API TargetUnitsPet|TargetUnitsPet("unit")]] function to target a pet.
: 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.
{{WoW API}}

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.