Thread Tools Display Modes
10-17-20, 11:47 AM   #1
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Setting a CVar doesn't work when including it in an addon

Hi.

Apparently CVars aren't being saved when you log out (well, some aren't being saved) so I gotta hit a macro with the following CVars everytime I log in:

Code:
/run SetCVar ("nameplateSelfTopInset", .55)
/run SetCVar("nameplateSelfAlpha", 1)
but as you can guess, having to hit a macro every time you log in just to have UI looking like you want it to is a bit annoying, so I made a simple addon and included these SetCVars in the addon - nothing major, it's basically the code above just without the /run part.

However it doesn't work at all. I still gotta hit the macro everytime I log in and the altered cvars reset themselves upon logout/reload UI. What am I missing here, what can I do?
  Reply With Quote
10-17-20, 04:51 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You have to wait until after the VARIABLES_LOADED event fires or your changes will just get reverted back when the cvar settings are loaded.
  Reply With Quote
10-17-20, 08:23 PM   #3
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Originally Posted by Vrul View Post
You have to wait until after the VARIABLES_LOADED event fires or your changes will just get reverted back when the cvar settings are loaded.
How do I implement this?

Originally Posted by sezz View Post
Are you using another addon that modifies nameplates in some way? They usually change those settings.
Yeah I'm using KUI nameplates but it didn't behave like this before (+I have personal resource bar disabled in KUI). How do I override the addon overriding the defaults (if it's in fact indeed overriding it)?
  Reply With Quote
10-18-20, 03:23 PM   #4
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Originally Posted by Kenjub View Post
KUI nameplates
Looks like you can set those cvars in the config somewhere (I don't use KUI nameplates, just had a quick look at the code):

SetCVar('nameplateSelfTopInset',core.profile.cvar_self_clamp_top) is called "Self clamp top"
SetCVar('nameplateSelfAlpha',core.profile.cvar_self_alpha) is called "Self alpha"

The personal resource bar is just a nameplate, most nameplate cvars apply to it aswell, doesn't matter if you disable personal resource bar modifications in KUI nameplates.
  Reply With Quote
10-18-20, 04:15 PM   #5
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
Originally Posted by Kenjub View Post
How do I implement this?

Code:
local EventFrame = CreateFrame("Frame")
EventFrame:RegisterEvent("VARIABLES_LOADED")
EventFrame:SetScript("OnEvent", function(_, event)

   SetCVar ("nameplateSelfTopInset", .55)
   SetCVar("nameplateSelfAlpha", 1)

end)
  Reply With Quote
10-19-20, 06:36 AM   #6
Kenjub
A Deviate Faerie Dragon
Join Date: Jul 2018
Posts: 15
Originally Posted by sezz View Post
Looks like you can set those cvars in the config somewhere (I don't use KUI nameplates, just had a quick look at the code):

SetCVar('nameplateSelfTopInset',core.profile.cvar_self_clamp_top) is called "Self clamp top"
SetCVar('nameplateSelfAlpha',core.profile.cvar_self_alpha) is called "Self alpha"

The personal resource bar is just a nameplate, most nameplate cvars apply to it aswell, doesn't matter if you disable personal resource bar modifications in KUI nameplates.
I actually tried disabling KUI to see if it's related to KUI and it isn't, so your solution doesn't seem viable

Originally Posted by Tim View Post
Code:
local EventFrame = CreateFrame("Frame")
EventFrame:RegisterEvent("VARIABLES_LOADED")
EventFrame:SetScript("OnEvent", function(_, event)

   SetCVar ("nameplateSelfTopInset", .55)
   SetCVar("nameplateSelfAlpha", 1)

end)
Thanks for taking the effort but it doesn't seem to work any other ideas you might have?
  Reply With Quote
10-17-20, 05:13 PM   #7
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
Are you using another addon that modifies nameplates in some way? They usually change those settings.
  Reply With Quote
10-20-20, 09:11 AM   #8
sezz
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 158
You could try disabling ALL your addons - if you set a cvar (even if you only do it with a macro) and it changes back after relogging or reloading the UI there's most likely some other addon changing it.

If it works without any other addons you can either renable your addons one by one or use an editor that can search in all files in a directory (VS Code or Sublime Text for example) and search for nameplateSelfTopInset and nameplateSelfAlpha in your addons directory.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Setting a CVar doesn't work when including it in an addon

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off