Run CVars depending on location?

Hi there,

I’m using AdvancedInterfaceOptions addon which allows to set a lot of values to the various CVars in the game.

Specifically, I am looking to change the values of some CVars automatically depending on my location - this would be Org, Battlegrounds, and Dungeons.

The CVars in question would be “nameplateShowAll” and “nameplateMaxDistance”.

I want to turn OFF “nameplateShowAll” in friendly territories like Org/Stormwind, but turn it on in Battlegrounds, Dungeons.

I also want to set the “nameplateMaxDistance” to 100 in Battlegrounds, but something like 50 for Dungeons.

Is it possible to have some script that automatically changes these depending on my location?

Thank you very much.

Could probably setup a WeakAura to do it.

I’m only aware of using weakauras to track spells and buffs and things like that. I’m not sure how to enter scripts on it…

Do a search on wago.io for cvar. Should be able to find someone else’s WA you can use as a starting point.

1 Like

What is the difference between setting a trigger in the “Trigger” tab and setting the boxes in the “load” tab? In the “load” tab I can simply select the Zone ID’s or for example the box that says “Battleground”

Load controls whether or not the auras are checked at all. Triggers are for when a state you care about changes.

1 Like

Is this syntax correct?

The event triggering it is ZONE_CHANGED_INDOORS

function()
SetCVar(“nameplateMaxDistance”, 100)
SetCVar(“nameplateShowFriends”, 1)
SetCVar(“nameplateShowEnemies”, 1)
SetCVar(“nameplateShowAll”, 1)
end

You can no longer adjust nameplate distance.
And the proper command is C_CVar.SetCVar()

1 Like

That doesn’t work, it returns red text that says

[string “return C_CVar.SetCVar()…”]:2: ‘’ expected near ‘SetCVar’

If the criteria is instanced content, I might recommend using PLAYER_ENTERING_WORLD and GetInstanceInfo(). You can adapt this to WA:

local f = CreateFrame("Frame")
f:SetScript("OnEvent",function(self,event,...)
  if select(2,GetInstanceInfo())=="none" then
    -- you are not in an instance
  else
    -- you are in an instance
  end
end)
f:RegisterEvent("PLAYER_ENTERING_WORLD")
1 Like

Do I copy-paste that code exactly as you have it there? Do I have to create/set any values for any variables?

Stick the cvar logic you want to execute in the appropriate parts of the if statement.

Then you can stick the code in the same addon you created with Gello’s code in the other thread.

Yeah put your code you want to run when not in an instance under this line:

-- you are not in an instance

And then put your code you want to run in an instance under this line:

-- you are in an instance

And then copy/paste it all to https://addon.bool.no/ to turn it into a standalone addon. (You’ll need to load out of date addons; that site is still on 9.2 patch.)