WoW:API CheckInteractDistance: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Update values using tab-targeting method)
m (Move page script moved page API CheckInteractDistance to API CheckInteractDistance without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}}
{{wowapi}}


Returns 1 if you are in range of the specified unit to perform the action specified by distIndex (returns nil otherwise).
Checks whether you are in range to perform a specific interaction with a specified unit.
inRange = CheckInteractDistance("unit", distIndex);


----
==Arguments==
;''Arguments''
;unit : String - [[UnitId|Unit]] to compare distance to.
;distIndex : Number - A value from 1 to 4:
::1 = Inspect, 28 yards
::2 = Trade, 11.11 yards
::3 = Duel, 9.9 yards
::4 = Follow, 28 yards


:(String unit, Int distIndex)
==Returns==
;inRange : Boolean flag - 1 if you are in range to perform the interaction, nil otherwise.


:;unit : The unit to query (e.g. "target", "party1", "pet", "player")
==Example==
:;distIndex : A value 1-4:
:::1 = Inspect, 30 yards
:::2 = Trade, 11.11 yards
:::3 = Duel, 9.9 yards
:::4 = Follow, 30 yards
 
----
;''Returns''
 
:;canInteract : If in range to perform the action, 1 (true).  Otherwise, nil (false).
 
----
;''Notes''
 
:If "unit" is a hostile unit, the return values are the same.  But you obviously won't be able to do things like Trade.
 
:There may also be more values for distIndex that we don't know about.
 
:Patch 2.1 changed trade distance to 11.11 yards, but this was later reverted.
 
----
;''Example''
  if ( CheckInteractDistance("target", 4) ) then
  if ( CheckInteractDistance("target", 4) ) then
   FollowUnit("target");
   FollowUnit("target");
Line 36: Line 21:
   -- we're too far away to follow the target
   -- we're too far away to follow the target
  end
  end
==Notes==
* If "unit" is a hostile unit, the return values are the same.  But you obviously won't be able to do things like Trade.

Latest revision as of 04:45, 15 August 2023

WoW API < CheckInteractDistance

Checks whether you are in range to perform a specific interaction with a specified unit.

inRange = CheckInteractDistance("unit", distIndex);

Arguments[edit]

unit
String - Unit to compare distance to.
distIndex
Number - A value from 1 to 4:
1 = Inspect, 28 yards
2 = Trade, 11.11 yards
3 = Duel, 9.9 yards
4 = Follow, 28 yards

Returns[edit]

inRange
Boolean flag - 1 if you are in range to perform the interaction, nil otherwise.

Example[edit]

if ( CheckInteractDistance("target", 4) ) then
  FollowUnit("target");
else
  -- we're too far away to follow the target
end

Notes[edit]

  • If "unit" is a hostile unit, the return values are the same. But you obviously won't be able to do things like Trade.