Edit 2 - Nevermind, I'm stupid. I forgot to make the variable in question global before using 3rd party addons to check its value.
I have an addon that mutes the game sound at certain times by adjusting the CVar "Sound_EnableSFX". Trouble is right now the game sound stays off for good until manually re-enabled, and I want my addon to re-enable it when said time is over.
So what I'm trying to do is store the current value of Sound_EnableSFX in a variable at addon load time. This isn't working. In my ADDON_LOADED event I have the following:
gomlsfxdefault = GetCVar("Sound_EnableSFX");
Well gomlsfxdefault is still nil. Okay, so I figure maybe CVars are loaded after addons and I can't get it then.
My sound muting is triggered by a specific aura I'm watching for, so I figured I would just grab the CVar before registering for the UNIT_AURA event instead, which isn't registered at load time but well after the player has entered the world like so:
Code:
if not (GOMLCore:IsEventRegistered("UNIT_AURA")) then
--See if we can capture the current sound setting
gomlsfxdefault = GetCVar("Sound_EnableSFX");
GOMLCore:RegisterEvent("UNIT_AURA");
end
Once again however, no dice. gomlsfxdefault is still nil when my addon has registered the UNIT_AURA event.
So does anyone know what's up? Am I just doing this wrong?
Edit - Upon further investigation, GetCvar("Sound_EnableSFX")
does work at load time, which only serves to further baffle me. I even tried this:
Code:
if GetCVar("Sound_EnableSFX") then
gomlsfxdefault = 1;
DEFAULT_CHAT_FRAME:AddMessage("The variable should be set now")
end
And even though GetCVar("Sound_EnableSFX") returns 1 at load time, and I get the chat message, it STILL won't set the variable.