WoW:API UnitInRange: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
Line 19: Line 19:
  if UnitInRange("target") then
  if UnitInRange("target") then
     print(UnitName("target") .. " is 40 yds away.")
     print(UnitName("target") .. " is 40 yds away.")
  elseif not UnitInRange("target") then
  else
     print(UnitName("target") .. " is not in range!")
     print(UnitName("target") .. " is not in range!")
  end
  end

Revision as of 12:14, 28 January 2018

WoW API < UnitInRange

Returns 1 if the unit is in range (40yds) and "Line of Sight" of most helpful spells, nil otherwise.

isTrue = UnitInRange("unit")

Arguments

unit
String - unitId to check.

Returns

isTrue
1 or nil

Example

if UnitInRange("target") then
    print(UnitName("target") .. " is 40 yds away.")
else
    print(UnitName("target") .. " is not in range!")
end

Result

FarfarawayDPS is 40 yds away.
FarfarawayDPS is not in range!

Details

Returns 'false' for any unit not in party or raid.
Will return nil for hostile units.

See also