The important bit, which should be stressed above all else, is that OnValueChanged will happen BEFORE variables are loaded. It's part of a slider's initialization when the game loads up.
Do you have DiivSkinSettings defined outside the functions above? Looking at it more closely I wonder that you don't get nil errors in the initial OnValueChanged.
If your mod looks like:
Code:
function OnLoad()
this:RegisterEvent("VARIABLES_LOADED")
end
function OnEvent()
if event=="VARIABLES_LOADED" then
DiivSkinSettings = {}
DiivSkins_hbar1Update();
end
end
Then in the xml:
<OnValueChanged>
DiivSkinSettings.hbar1 = this:GetValue();
DiivSkins_hbar1Update();
</OnValueChanged>
is going to be a mess. Because DiivSkinSettings is not defined yet. (OnValueChanged will get called BEFORE variables are loaded)
You can do this:
Code:
DiivSkinSettings = {}
function OnLoad()
this:RegisterEvent("VARIABLES_LOADED")
end
function OnEvent()
if event=="VARIABLES_LOADED" then
DiivSkins_hbar1Update();
end
end
By moving DiivSkinSettings = {} outside the functions, when the xml is loaded and it hits the Script file="whatever.lua", it will run the lua file and make DiivSkinSettings = {} before anything happens in your xml.
Or you can do
Code:
<OnValueChanged>
if DiivSkinSettings then
DiivSkinSettings.hbar1 = this:GetValue();
DiivSkins_hbar1Update();
end
Other stuff I notice:
Code:
<OnShow>
if (DiivSkinSettings.hbar1) then
this:SetValue(DiivSkinSettings.hbar1);
end
</OnShow>
If DiivSkinSettings isn't defined yet (ie, if before VARIABLES_LOADED), then this will give an error. It's trying to see if a value beneath an undefined table exists.
When checking if something exists, if it's a table then the elements above it must exist or it will give an error. the above should read:
Code:
<OnShow>
if DiivSkinSettings and DiivSkinSettings.hbar1 then
this:SetValue(DiivSkinSettings.hbar1);
end
</OnShow>
If DiivSkinSettings doesn't exist it will fail right away. If it exists it will see if hbar1 beneath it exists.
But again, realize that OnValueChanged() gets called BEFORE VARIABLES_LOADED. You may think OnValueChanged() is the result of someone moving the slider but it can (and is) also the UI setting the default value.