API UnitExists

From Wowpedia
Jump to: navigation, search

Determines if the unit exists.

exists = UnitExists("unit")

Arguments

unit 
String - The UnitId of the unit to check (Tested with "player", "pet", "party1", hostile "target")

Returns

exists
Boolean - true if the unit exists and is in the current zone, or false if not

Example

The snippet below prints a message describing what the player is targeting.

if UnitExists("target") then
 print("You're targeting a " .. UnitName("target"))
else
 print("You have no target")
end