View Single Post
06-08-05, 04:57 PM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
At a casual glance, a couple things throw up flags for me:

else if not (DiivSkinSettings) then
DiivSkinSettings.hbar1 = {}
end

If the above happens, then it will give an error. The above says if this table doesn't exist, then create a subtable under this non-existent table.

What you probably want is:

else if not (DiivSkinSettings) then
DiivSkinSettings = {}
DiivSkinSettings.hbar1 = (some default value)
end

On the value not chaning right away: A slider's OnValueChanged will get called BEFORE your variables are loaded. As part of a slider's initialization it will call OnValueChanged. This may be why its last state is not being saved initialially. I don't see a DiivSkins_hbar1Update() but I suspect it's assuming variables are loaded and they're not yet. (and in fact it'd be overwritten by this:GetValue())

How I handle sliders is this:
1. In the mod's initialization, after VARIABLES_LOADED, I slider:SetValue(last position)
2. In the slider's OnValueChanged() function, I check first if the mod is loaded, and if it is, then I assume the current position is valid and work with it from there.

When troubleshooting a sequence of events I'll often pepper my code with a lot of DEFAULT_CHAT_FRAME:AddMessage("In OnValueChange now") and stuff like the above will stand out right away.
  Reply With Quote