-
Posted by billtopia on Fri, 25 Feb 2011 21:29:09
I wrote the following section of code for saveing the values of sliders on several addons but there seems to be an error for atleast 1 person where it doesn't save the value for them. Is there something not quite right about this code? Is it a problem that the person is in Italy? I would have thought not...
Panel is the registered control panel frame that contains the slider.
Slider is the string name of the slider.
Table is the table that the saved variable is in.
Key is the string name of the variable that holds the saved value.
-- Checks Slider against variable and changes var if needed
BillsUtils.SliderSave = function( Panel, Slider, Table, Key)
if type(Key) ~= "string" then Key = Slider end local SliderValue = Panel[Slider]:GetValue() local SavedValue = Table[Key] if SliderValue ~= SavedValue then Table[Key] = SliderValue end
end
-
Posted by jnwhiteh on Fri, 25 Feb 2011 22:29:21
It's just a bit more complicated than it needs to be. No need to check and see if the value is different than what is stored.. you can just store it. The code is simpler and even less confusing.
-
Posted by billtopia on Mon, 28 Feb 2011 02:23:21
Guess the checking the stored variable goes to not wanting to overwrite the default metatable data if it isn't needed to be. But besides checking to see if I need to change the value I take your response to be you see no reason that it wouldn't save the value for the 1 person that I know about not having it saved?
-
Posted by jnwhiteh on Mon, 28 Feb 2011 08:36:19
Correct. If you're messing with 'defaults', I HIGHLY suggest using AceDB3. I wrote it, and every single time I think I can do better than using a library for it, I end up screwing it up. The code has been so thoroughly tested and reviewed.. it's actually the best there is in that regard.
-
Posted by billtopia on Wed, 02 Mar 2011 19:59:12
Thanks, I will have to look at AceDB3 or Ace in general. I need to figure out which would be easier and better. The current version of Achievement Sounds or an Ace version. Since I am still learning Lua it makes sense that I may as well learn other things that may help improve my addon skill set.
-
Posted by jnwhiteh on Wed, 02 Mar 2011 20:03:52
Well, Ace is just a collection of libraries, you can use AceDB without using anything else =)