WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   OnMouseUp and mouseover (https://www.wowinterface.com/forums/showthread.php?t=58455)

Noctys 12-11-20 05:17 PM

OnMouseUp and mouseover
 
I last created Mods back before Cataclysm. It's been a long time. Just now getting back into it. I'm just trying to write a very basic mod that cancels attacking with the right mouse button.

Code:

WorldFrame:HookScript("OnMouseUp", function(self, button)
    if button == "RightButton" then
        local mouseoverName = UnitName("mouseover") or "Unknown";
        local reaction = UnitReaction("mouseover", "player") or 10;
        if reaction < 5 then                       
            DEFAULT_CHAT_FRAME:AddMessage("Stopped Attack on: "..mouseoverName);
            MouselookStop();
        else
            DEFAULT_CHAT_FRAME:AddMessage(mouseoverName.." is friendly! "..reaction);
        end
    end
end)

The code I have should be working (from what I can tell) - but it's not. The code always returns Unknown & 10. If I swap out `mouseover` for `player` it works fine (but doesn't actually give me the data I need).

Also, if I swap out and hook-into `OnMouseDown` it also works, but then I can't actually interrupt the attack.

Any insight on why it's not working or how to fix it would be appreciated... Also if there is just a better way to do things I'm all ears.


All times are GMT -6. The time now is 05:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI