Saturday, April 21, 2012

Simple - How to identify the target??

Hi, I've searched the wowwiki and even screwed around but I can't seem to find the right variable. Here is some example code of what I'm trying to do:


Code:
if ("target" ==nil) then
WhatsTargetted = "Nothing";
elseif ("target" ~=nil) then
WhatsTargetted = "target"; -- This is what is always run, obviously
end;

if (WhatsTargetted ~="Nothing") then
SendChatMessage("I have you targetted", "WHISPER", this.language, WhatsTargetted);
else
DEFAULT_CHAT_FRAME:AddMessage("Nothing is targetted");
end;

I'm having trouble finding the variable that stores what the player is currently targetting. That same variable should be nil or "" if there is nothing targetted, right?

"target" obviously doesn't seem to be it..

Thanks so much in advance!|||Code:
UnitName("target")

Will return the name of the target (or nil for no target), if this is what you mean.|||Hi,

The solution towards finding out things about your current target is (mainly) the so called WoW unit functions. You can find an excellent summary here:

http://www.wowwiki.com/World_of_Warc...Unit_Functions

Each of these functions returns a specific piece of information about a unit. A unit is identified by a string and the string "target" relates to .... the current target. As mentioned int he privous reply the functions call "UnitName("target")" gives you the name of your current target, or nil if there is no target. As you can see there are some 30 to 40 other functions related to units that you might find useful.

Have a look here to find out what other units are supported by those functions:

http://www.wowwiki.com/UnitId

Skeeve|||Quote:









Code:
UnitName("target")

Will return the name of the target (or nil for no target), if this is what you mean.




This is exactly what I was looking for. Thank you!

No comments:

Post a Comment