Thread Tools Display Modes
08-27-08, 03:17 PM   #1
Scale
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 28
UnitName("unit") error

when leaving/joining raids this line sometimes gives me the error:

Usage: UnitName("unit")

local tarname = UnitName(tarframe:GetAttribute("unit"))

Now i want to create an If so it doesn't error but i don't have a clue what to check so it bypasses this line if i guess the GetAttribute("unit") is empty.
  Reply With Quote
08-27-08, 03:29 PM   #2
TheOneAndLonely
A Murloc Raider
 
TheOneAndLonely's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 5
Cant you just test with:

if ( IsUnit("unit") ) then
...
end;
__________________
___________________________
If it ain't broken don't break it
  Reply With Quote
08-27-08, 03:31 PM   #3
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
if tarframe:GetAttribute("unit") then ...

(better yet: )
local target = tarframe:GetAttribute("unit");
local tarname;
if target then
tarname = UnitName(target);
end
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
08-27-08, 03:31 PM   #4
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
Originally Posted by TheOneAndLonely View Post
Cant you just test with:

if ( IsUnit("unit") ) then
...
end;
You misread the question. He does not know the unit id.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
08-27-08, 03:36 PM   #5
TheOneAndLonely
A Murloc Raider
 
TheOneAndLonely's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 5
On second thought that is a vidget like GameTooltip:IsUnit("unit")
dont know if u can use it in some way
__________________
___________________________
If it ain't broken don't break it
  Reply With Quote
08-27-08, 03:40 PM   #6
TheOneAndLonely
A Murloc Raider
 
TheOneAndLonely's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 5
ahh sorry was way off there

But you got a nice and working reply now i see
__________________
___________________________
If it ain't broken don't break it
  Reply With Quote
08-27-08, 04:29 PM   #7
Scale
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 28
Dam fast and perfectly working!
Altough i should have tought of this myself but you cant do everthing on your own so im glad you guys could help out
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » UnitName("unit") error


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off