Adjust Macro based on Covenant

To do this you need to use a Variable. (See Macro Variables for more on Variables)

eg ~~COVENANTABILITY~~

function() 
    local covenantID =  C_Covenants.GetActiveCovenantID(); 
    if covenantID == 1 then
        -- Kyrian 
        return "/cast Divine Toll"
    elseif covenantID == 2 then
        -- Venthyr
        return "/cast venthyrability"
    elseif covenantID == 3 then
        -- Night Fae
        return "/cast nightfaething"
    elseif covenantID == 4 then
        -- Necrolord
        return "/cast necrolordstuff"
    else
       -- Not in a Covenant
       return "/cast null"
    end
end

Obviously you change what the covenant abilities return depending on the macro.

for a castsequence version you could do the following if you were in the Kyrian Covenant

function() 
    local covenantID =  C_Covenants.GetActiveCovenantID(); 
    if covenantID == 1 then
        -- Kyrian 
        return "Divine Toll,"
   else
       -- Not Kyrian just skip this 
       return
   end
end

Catch me on Twitch

4 Likes

Good stuff. I added a variable into my VDH macro some time ago to cast or not Sigil of Flame based on whether you were wearing a particular legendary. Similar principle.

Hey there, new to this addon/forum. With the onset of 9.1.5 I’m looking for something like this to make it easy to swap between covenants as Warrior - I tried to replicate the code and replace the abilities but am not sure how to get it to work properly. Any help is appreciated!

This example is for GSE2 - you will need to create a Variable that returns True/False for a covenant and use that in conjunction with IF blocks in GSE3

eg - Create a variable called “Kyrian”

function() 
    local covenantID =  C_Covenants.GetActiveCovenantID(); 
    if covenantID == 1 then
        -- Kyrian 
        return true
   else
       -- Not Kyrian 
       return false
   end
end

In the true side of the block - add what you would do if you were kyrian. on the false side - what you would do if you weren’t kyrian. This could be other if blocks for other covenants on even nothing

so the function returns the covenant ability based on my covenant?

how do i actullay make use of it in a macro?

Either use the true/false variable with an If block or refer to the variable within your action like any other variable in GSE3

Hi, can someone explain this to me like I’m 5. How do I actually make this work. So I have that initial function in GSE, but I can’t seem to utilize it further. I named it covenantability which I presume is the actual variable, but what then. Tried reading about it, but I have a hard time taking it home. Sorry if this is a noob thing, and thanks for answering.

1 Like

Same here. I put this code into a block but it doesn’t do anything. I haven’t coded since BASIC in the 1980’s :frowning:

You put the code into a variable and then you refer to it in your block. KeyPress is a variable. Every time GSE sees ~~KeyPress~~ it replaces that with the contents of your variable. This is the next level however instead of just doing a straight string swap it’s replacing with the outcome of your function.

Now if the function is returning a string ( eg return “/cast divine toll”) it can just drop that in like it did with ~~KeyPress~~.

However if that function is returning a true or false then you need to use a IF Block not an Action Block. The IF block will ask what variable do I look at so it knows if it’s a true or false state and have two containers of blocks that look like how the loop blocks look. One for true, and kind for false. Each of these containers can contain multiple action blocks.

I can’t make it any simpler - either you’re going to understand this or you aren’t. Function variables like this are pure Lua, WoW’s programming language. Unfortunately for some of these situations there is no simple alternative.

Abilities work but the icon doesn’t seem to update. Rather it updates only after the key press and stays the same until the subsequent key press.

#showtooltip
/use ~~MOD_CovenantAbility~~
/use [@mouseover,help,spec:3]  Riptide
/use [@mouseover,harm]  Flame Shock;Flame Shock

with variable

function()
 local covenantID = C_Covenants.GetActiveCovenantID();
 if covenantID == 1 then
-- Kyrian
return "[mod, @cursor] Vesper Totem"
 elseif covenantID == 2 then
return "[mod, @mouseover] Chain Harvest"
elseif covenantID == 3 then
return "[mod, @cursor] Fae Transfusion"
elseif covenantID == 4 then
return "[mod, @mouseover] Primordial Wave"
 else
return
 end
end

#showtoolip has no meaning in a GSE template and can cause issues. This is handled by the stubmacro and is based on what WoW can see without considering any mods from your compiled template