Tab target mode keybind changing

I’m trying to make a simple one-button push macro that switches my keybinding on Tab from “target nearest enemy” to “target nearest friend” and back again, and if possible i would like the same button to activate the keybind to swap between showing friendly nameplates on/off and reversely showing enemy nameplates off/on.

In other words, I want a button that swaps between “healer mode” and “damage mode” so I can quickly flip between tab-targeting friendlies with friendly nameplates on, and then when i hit the button, target enemies with enemy nameplates on instead. Is this at all possible to do with macros?

Here’s the macro version:

/run if GetCVar("nameplateShowFriends") == '1' then SetBinding("TAB","TARGETNEARESTENEMY");SetCVar("nameplateShowFriends", 0);else SetBinding("TAB","TARGETNEARESTFRIEND");SetCVar("nameplateShowFriends", 1) end

And here’s the more readable lua version:

if GetCVar("nameplateShowFriends") == '1' then
   SetBinding("TAB","TARGETNEARESTENEMY")
   SetCVar("nameplateShowFriends", 0)
else
   SetBinding("TAB","TARGETNEARESTFRIEND")
   SetCVar("nameplateShowFriends", 1)
end

As you can probably tell “TAB” is refering to the key that you want to bind the targeting to and would have to be replaced by the desired button.


Important:

The macro will probably not work in the way you want. Both used functions SetBinding() and SetCVar are protected. That means they can not be called in combat.

So switching between the 2 “modes” would only be possible when not in combat.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.