After some trial and error it looks like I get the data I need with OnMouseDown instead of using OnMouseUp -- however, doing it that way I can't cancel the attack.
- Registered User
Member for 2 years
Last active Sat, Dec, 12 2020 16:36:12
- 0 Followers
- 3 Total Posts
- 0 Thanks
Dec 11, 2020Posted in: Lua Code Discussion
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.
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. I'm guessing that the unitId "mouseover" is no longer valid because if I swap it out for "player" it works fine. 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.
- To post a comment, please login or register a new account.