Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

API UnitExists

From Wowpedia
Jump to: navigation, search

Determines if the unit exists.

exists = UnitExists("unit")

Arguments

unit 
String (UnitId) - The unit to query (e.g. "player", "party2", "pet", "target" etc.)

Returns

exists 
Flag - 1 if the unit exists and is in the current zone, or nil 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