View Single Post
03-15-22, 05:19 PM   #1
muleyo
A Deviate Faerie Dragon
Join Date: Apr 2021
Posts: 12
CVars set via addon reset when entering Interface options

Hi,

I'm currently setting CVars via AddOn (nameplate-related to be specific). Unfortunately, the CVars reset whenever I go to Interface options... I tried resetting my Interface, that didn't fix the issue.

Any1 has an idea?

Edit: NamePlateVerticalScale always resets to its default value by InterfaceOptionsPanel.lua

Here's the code of InterfaceOptionsPanel.lua:

Code:
function InterfaceOptionsLargerNamePlate_OnLoad(self)
	function self:GetValue()
		if self.value then
			return self.value;
		end
		if math.abs(tonumber(GetCVar("NamePlateHorizontalScale")) - self.normalHorizontalScale) < .001 and
			math.abs(tonumber(GetCVar("NamePlateVerticalScale")) - self.normalVerticalScale) < .001 and
			math.abs(tonumber(GetCVar("NamePlateClassificationScale")) - self.normalClassificationScale) < .001 then
			return "0";
		end
		return "1";
	end

	function self.setFunc(value)
		if value == "1" then
			SetCVar("NamePlateHorizontalScale", self.largeHorizontalScale);
			SetCVar("NamePlateVerticalScale", self.largeVerticalScale);
			SetCVar("NamePlateClassificationScale", self.largeClassificationScale);
		else
			SetCVar("NamePlateHorizontalScale", self.normalHorizontalScale);
			SetCVar("NamePlateVerticalScale", self.normalVerticalScale);
			SetCVar("NamePlateClassificationScale", self.normalClassificationScale);
		end
		NamePlateDriverFrame:UpdateNamePlateOptions();
	end

	self.type = CONTROLTYPE_CHECKBOX;
	self.defaultValue = "0";
	BlizzardOptionsPanel_RegisterControl(self, self:GetParent():GetParent());
end
Unfortunately, I got no clue how to prevent that.

Last edited by muleyo : 03-15-22 at 06:41 PM.
  Reply With Quote