View Single Post
10-06-16, 12:42 AM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Either of those should generally work, but the name of the CVar is a string, so it needs to be quoted:
Code:
SetCVar("showQuestTrackingTooltips", 1)
Without quotes, you're passing SetCVar a variable name, but since there is (probably) no variable with that name, SetCVar will either throw an error, or just ignore you.

Also, "f" should be a local variable (put a "local" keyword at the beginning of the first line). Putting "f" into the global namespace is just begging for conflicts -- and if Blizzard ever leaks a global "f" you could potentially break the whole UI, which actually happened with "_" when Cataclysm launched.

Finally, you can shorten things up a bit with ternary syntax.

Code:
local f = CreateFrame("Frame")
f:RegisterEvent("GROUP_ROSTER_UPDATE")
f:SetScript("OnEvent", function(self, event)
	SetCVar("showQuestTrackingTooltips", IsInRaid() and 0 or 1)
end)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote