How to clear raid marker on focus when removing focus

What I want is to be able to mouse over a target, press a button, and have it be set to focus and also apply raid marker if it doesn’t have one already. So far I have this (slightly modified from quazii’s latest video)

/focus [@mouseover,exists,nodead] []
/run if (UnitExists("focus") and not GetRaidTargetIndex("focus")) then SetRaidTarget("focus",5) end

But when I remove my focus by mousing over nothing and using the macro, the focus is removed but the raid marker remains. How can I additionally have the raid marker removed when I remove focus?

Stick this at the top

/tm [@focus,exists] 0
1 Like

Ahh very smart thank you I didn’t consider just “clearing” it every time at the start!

Actually testing it some more, I realized that this almost works, but if there is another raid marker already assigned, it will replace that existing marker with my marker (after two clicks)

Any ideas on how to change the first line to only remove the raid marker IF it’s the one I use later, which in my case is 5? The idea here is I don’t want to remove someone else’s raid marker

Would be something like…

/run if (not UnitExists("mouseover") and UnitExists("focus") and GetRaidTargetIndex("focus") == 5) then SetRaidTarget("focus",0) end
/focus [@mouseover,exists,nodead] []
/run if (UnitExists("focus") and not GetRaidTargetIndex("focus")) then SetRaidTarget("focus",5) end

Very nice thank you that worked. It went over character limit so I’ve slightly modified it:

/run f="focus"
/run if (not UnitExists("mouseover") and UnitExists(f) and GetRaidTargetIndex(f) == 5) then SetRaidTarget(f,0) end
/focus [@mouseover,nodead]
/run if (UnitExists(f) and not GetRaidTargetIndex(f)) then SetRaidTarget(f,5) end

Thanks again very nice!

2 Likes

Using a global variable as generic as f probably isn’t wise. Not sure if making it local will break things cuz of the separate run commands though.

/run local f="focus" if (not UnitExists("mouseover") and UnitExists(f) and GetRaidTargetIndex(f) == 5) then SetRaidTarget(f,0) end
/focus [@mouseover,nodead]
/run if (UnitExists(f) and not GetRaidTargetIndex(f)) then SetRaidTarget(f,5) end

More optimized (if the separate runs don’t mess it up)

/run local f,UE,GR,SR="focus",UnitExists,GetRaidTargetIndex,SetRaidTarget if (not UE("mouseover") and UE(f) and GR(f) == 5) then SR(f,0) end
/focus [@mouseover,nodead]
/run if (UE(f) and not GR(f)) then SR(f,5) end
1 Like