Thread Tools Display Modes
02-25-11, 08:47 PM   #1
BlueSixty
A Murloc Raider
 
BlueSixty's Avatar
Join Date: Feb 2011
Posts: 6
Get a UnitID

I would like to create a var to hold a unitID and then use that var in functions that take the unitID as a parameter. I can't seem to determine how to get a unitID though.

Code:
SetRaidTargetIcon("mouseover", 8)
Sets the skull on the mouseover target

Code:
local name = UnitName("mouseover")
SetRaidTargetIcon(name, 8)
does nothing.

Is there another function that will get the UnitID instead of the name?
  Reply With Quote
02-25-11, 09:16 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Your id is "mouseover". Why not use this ?
UnitIds are nothing static. So there is no (easy) way to know what unitId to chose for a unit. If you set yourself to focus and target and then mouseover your unit ... which unitId should the function return ?
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
02-28-11, 07:10 PM   #3
BlueSixty
A Murloc Raider
 
BlueSixty's Avatar
Join Date: Feb 2011
Posts: 6
Post

That was just a simplified example.

My addon will allow you to assign a keybinding. When you press that key I grab the unit the mouse is over, then show a frame. Later I want to interact with the mouseover unit, but the mouse is now over my frame, so "mouseover" isn't the unit anymore.

the following is a better example
Code:
function myKeyPressed()
    local name = UnitName("mouseover")
 
    displayMyFrame() --The frame will be under the cursor/pointer
    doSomethingElse(theUnit)
end

function doSomethingElse(theUnit)
    SetRaidTargetIcon(theUnit, 8)
end
The above code doesn't work though.
  Reply With Quote
02-28-11, 09:03 PM   #4
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
You can’t create your own unit tokens, only use the ones Blizzard assigns, so what you wrote won’t work exactly the way you’re thinking. You could do something similar by storing the unit’s GUID the first time you moused over it and pressed the key to “store” it:

Code:
local storedGUID = UnitGUID( "mouseover" )
You can’t target the unit later, or do other stuff with it, unless it has a valid unit token again, but you can detect when you mouse over the same unit again (or target it, or do something else that gives it a unit token):

Code:
if UnitGUID( "mouseover" ) == storedGUID then
    -- You moused over the unit again.
end
If you just wanted to put a different raid icon on the mob, you just wave the mouse around on the screen and mark the mob when you the mouse passed over it.
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”

Last edited by Akkorian : 02-28-11 at 09:05 PM.
  Reply With Quote
03-01-11, 04:32 AM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
If you want to make a frame for anyone who is in your party or raid by hovering over them, that is possible via UnitIsUnit.
  Reply With Quote
03-01-11, 08:56 PM   #6
BlueSixty
A Murloc Raider
 
BlueSixty's Avatar
Join Date: Feb 2011
Posts: 6
ok, I think I understand how it works a little better now. I was thinking every unit had an ID I could collect and then use later in place of UnitID. I did play with the GUID but the same results as UnitName.

I don't I think I can accomplish what I wanted so I'll just have it work on the current target.

Thanks for all the help
__________________
---
Have a day :|
bluesixty
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Get a UnitID


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