WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Setting a CVar doesn't work when including it in an addon (https://www.wowinterface.com/forums/showthread.php?t=58310)

Kenjub 10-17-20 11:47 AM

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?

Vrul 10-17-20 04:51 PM

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.

sezz 10-17-20 05:13 PM

Are you using another addon that modifies nameplates in some way? They usually change those settings.

Kenjub 10-17-20 08:23 PM

Quote:

Originally Posted by Vrul (Post 337266)
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?

Quote:

Originally Posted by sezz (Post 337267)
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)?

sezz 10-18-20 03:23 PM

Quote:

Originally Posted by Kenjub (Post 337276)
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.

Tim 10-18-20 04:15 PM

Quote:

Originally Posted by Kenjub (Post 337276)
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)


Kenjub 10-19-20 06:36 AM

Quote:

Originally Posted by sezz (Post 337292)
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 :(

Quote:

Originally Posted by Tim (Post 337295)
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?

sezz 10-20-20 09:11 AM

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.


All times are GMT -6. The time now is 01:30 PM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI