LunaUnitFrames

LunaUnitFrames

268k Downloads

Requesting advice: initiating another addon's function on unit frame click

christo-san opened this issue ยท 1 comments

commented

Hi. I'm trying to add support for ClickHeal. I've looked through LunaUnitFrame code, but still having some issues identifying the correct location for event handling. The author of ClickHeal made it quite easy to support other addons, needing only to fire one of its functions upon player or target unit frame click and pass the unitID and the type of mouse click event.

My knowledge of lua is limited (I code mostly in Swift/Objective-C), but if you could point me in the right direction, I'd really appreciate it. Thank you!

Edit: Got a little closer to finding where I need to implement this function. Looks like in /modules/units.lua, I could drop this in local function OnClick()

Edit2: Ok I think I got it. Was wayyy easier than I made it out to be initially. Just had to rewrite OnClick() to:

local function OnClick()
    if Luna_Custom_ClickFunction then
        Luna_Custom_ClickFunction(arg1, this.unit)
    else
        CH_UnitClicked( this.unit, arg1 )
    end
end
commented

Just for future reference: The click binding can take funktions AND spells. Just assume that by the time your function is called the unit you clicked on is your current target. The target switches back to your old target when the function ends so you can't see the switching.