Thread Tools Display Modes
09-14-13, 12:06 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
UnitGUID issue in flex mode?

Someone posted this error in the comments on my tooltip mod

Message: Interface\AddOns\rTooltip\core.lua:128: Usage: UnitGUID("unit")
Time: 09/14/13 18:55:34
Count: 8
Stack: [C]: in function `UnitGUID'
Interface\AddOns\rTooltip\core.lua:128: in function <Interface\AddOns\rTooltip\core.lua:126>
[C]: ?

Locals: (*temporary) = nil
What I'm doing is the following:
Lua Code:
  1. local unit = select(2, self:GetUnit()) or (GetMouseFocus() and GetMouseFocus():GetAttribute("unit")) or (UnitExists("mouseover") and "mouseover")
  2. local guid = UnitGUID(unit) or nil
  3. if not guid then return end
Full code: http://code.google.com/p/rothui/sour...p/core.lua#125

I tested UnitGUID(unitID). When entering an invalid unitID it just returns nil.
What could make the function fail? It works flawlessly in any case I know. No issues with cross-realms.

I have not tested Flex raids yet. Am I missing something?

*edit* ------------------------
Ok...I think I forgot to catch nil and type. So going to add:
Lua Code:
  1. if not unit or (unit and type(unit) ~= "string") then return end

This should do it.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 09-14-13 at 12:40 PM.
  Reply With Quote
09-14-13, 04:31 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,325
You could do this:
Code:
local guid=unit and UnitGUID(unit);
If unit is nil, it won't run UnitGUID() and return nil. Otherwise, if UnitGUID() doesn't return anything useful, it'll return nil anyway.



If you want to check type too, you can do this:
Code:
local guid=(type(unit)=="string" and UnitGUID(unit) or nil);
Note the == operator will return a boolean value. If this doesn't matter to any following code, you may strip off the "or nil".
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 09-14-13 at 04:36 PM.
  Reply With Quote
09-14-13, 09:08 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I'm really tired and was out all day at a street fair, so I may be forgetting something. But why aren't you just using "mouseover" for your unit?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-15-13, 03:57 AM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
When you hover a unitframe you need to check for the unit attribute of that unitframe. Or check if the player target sth then self:GetUnit() will return a unit. I don't think mouseover works on unitframes.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
09-15-13, 04:06 AM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
I'm pretty sure hovering over a unit frame is just like hovering over the unit.
  Reply With Quote
09-15-13, 10:46 AM   #6
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Originally Posted by semlar View Post
I'm pretty sure hovering over a unit frame is just like hovering over the unit.
This is somewhat correct, it works the same within combatlog range, but not outside it.
(I think that's also rather new behavior, I know I noticed it around 5.3)

Last edited by Dridzt : 09-15-13 at 10:52 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » UnitGUID issue in flex mode?


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