saving tables as variables in the saved variables
Why is it exactly that when i try to dump a table to the saved variables it only picks up some of the table entry's?
|
well make sure its saving correctly
in your toc you need ##SavedVariables: or ##SavedVariablesPerCharacter: and you dont have to save them, they are just active you could have a addon that said Code:
if event == "VARIABLES_LOADED" then also make sure that you know that Code:
local table1, table2 = {1,2,3}, {4,5,6} Another thing is that your saved variables dont have to be tables, you could have MyAddonTimesLogged, MyAddonTimesDied and just have 2 numeric values. |
Well what im trying to do is... i have a chunk of code that deals with moving frames. It used to just build a table when the game loaded and those were your moveable frames. well... im trying to make things so that i can add/remove frames to that table from in game and have it save my additions/removels per session. I added another savevar to the .toc called GMoveableFrames. I tried to switch everything from that table to the saved variables but the big problem is on log out it only writes half of the frames it should to the saved variable file so on the next load up it does not load all the frames it should to the frame mover. I know this code might be a little confusing with out posting some of the other lua's in the addon but im pretty sure all important parts are there.
Code:
local addonName, addon = ... |
well, what does SetDefaultSettings (or whatever the function was called on line 3 or so) do? I dont see it in your copied code... does a VARIABLES_LOADED event happen to remove the defalut settings and set up your saved settings? I forget if PLAYER_LOGIN comes before or after, but if its after, PLAYER_LOGIN is a just as good.
|
this is the lua that contains the register settings information part of what makes this tricky is im using Vrul's LOD settings lib and AceGUI.
I also have the same problem with only pulling 8 of the table entrys when i try to make the config panel list out the current frames registered for moveing. Idealy the end product is that in game youll have panel on the config panel that has a add/remove frame button and shows you a list of current entrys. Code:
local addonName, addon = ... |
and thinking about it lol that registerdefault is trivial since it has nothing to do with the new variable added. it effects a different variable that is called GrimUISettings shorted by addon.settings
its trivial. all the functions pertaining to the moveable frames list are in that first chunk of code. |
perhaps a good place to start is to
/exit wow (or camp should do) and open up your WTF folder and find your addons saved variables. Make sure your saving what you think you are saving... if everything is in tact in your saved variables file, then your problem is with loading the addon, and not saving |
thats what im saying... stuff is not saved in the saved variable as it should be. why i have no idea.
That big list of frames where it says GMoveableFrames = { tons of stuff } shows up in the saved var as just 8 of the entrys rather then what? 30 of them |
No mater how i do it it has issues, maybe the way to do it is... create the table as before, then, have it add the stuff from the variables file to the table a different way like the table add entry function. then make the function for adding frames just write to the saved variable and the table? i dunno going to bed this is where i left off...
Code:
local addonName, addon = ... |
what is your SavedVariables name?
is it GMoveableFrames? cause that looks like it gets replaced anyhow everytime the default thing is called. lets say for instance that your saved variable is called MyAddonDB does anywhere in the file have MyAddonDB = GMoveableFrames? if it does, is it intended to copy all the values over? (because thats not what the above statement is saying) I think before you do a /reload you need to /dump MySavedVariable read whats actually in your table, do a /reload and look in your .lua... it should be an exact copy of what you just dumped. I know its not saving what your expecting, but honestly, i can hardly read whats going on in that code, i dont see anything about any saved variables anywhere. edit:: oh i see this now Code:
movedFrames = addon.settings.movedFrames |
GMoveableFrames and addon.settings.blahblah are BOTH saved variables in the toc file. The addon.settings.blahblah's are defined all through out the addon that is the general settings variable data.
addon.settings.blahblah stands for GrimUISettings in the toc file. your getting lost in the rest of the code... there is only two parts important to what is going on here... forget about the addon.settings variables they work just fine. its the GMoveableFrames and the moveableframes are the two things that are not working proper. moveableframes represents a table, and GMoveableFrames is supposed to represent your saved vars. On load the saved vars from GMoveableFrames should be loaded to table moveableframes. then on logout it should dump the table to the saved variables again to save any frames added or removed. I have tried doing this as just saved variables and ditching the table but i get the same result. no mater how i go about working this the max number of table entrys i can get to dump to the savedvariable is 8. even if i ditch ALL the code and just put GMoveableFrames = {list of entrys more then 8} it still only puts 8 of them in the saved var file. this little chunk Code:
function addon:DefaultMoveableFrames() Code:
--[[----------------------------------------------------------------------------- |
and this... this is what it s putting in the wtf.
Code:
GrimUISettings = { you see how GMoveableFrames has only 3 entrys? when gmoveableframes is set in the lua above it has like 30 entrys. |
I think I see your issue, but currently at work so I can't go into deep detail (coding on a phone sucks). It looks like you have a few spots where you're trying to copy tables but are instead just changing reference points. I'll double check when I get home this afternoon and post if someone doesn't beat me to it. ;)
EDIT: Also, you don't need to exit WoW to check your saved variables. They're saved after you /reload the UI. Much easier and less of a hassle that way. |
I must admit I don't overlook your code. (especially not the addon.RegisterEvent thingi ... where does it come from??)
But I know the addons code is loaded and exectuted before the saved vars are loaded - which means the DefaultMoveableFrames() stuff will be done and then GMoveableFrames will be loaded from the saved vars. Or? What happens if you delete the addons saved vars file? Does the new file then contain all the table entries from GMoveableFrames? |
Quote:
The way it should all work is... when you load the game the addon should check the saved vars for the GMoveableFrames entry, if it does not find it then it should load the big list of frames in the lua, if it does then it should load the list in the savedvars wtf instead. Then on log out save any frames added/removed. Which leads me to another question... would it be better for me to have the add remove frame function enter table entrys or should i make that function put the entrys in the saved var file? once i figure out how to get things to go back and forth properly... note - some of the way it should work i know is not right but when i did it the way i first thought i still had the only 8 entrys problem so i tried this way... and a few other ways. here is the registerevent functions... its in the core.lua Code:
--[[----------------------------------------------------------------------------- |
and you all think your confused... :) GrimUI has become a beast...
ok ok... i got a somewhat new idea... what if... instead of coping table to the saved var, I make it so there is the default table, then on AddonLoaded i have a function that checks the saved variables for the GMoveableFrames entry, if it finds it rather then try to copy it over i simply have the function do tinsert to the table for each GMoveableFrames entry. Make the addframe function put entrys into the saved vars and update the table. The only problem with that is that the frames in the main table could never be removed from in game... well they could but the first time you logged out and in it would reenter those frames because they are in the main table... you know whats real annoying to... is that other parts of the code that Vrul helped/did do exactly what we are talking about but i tried to copy his method and it didnt work lol. like that addon.settings.movedframes does exactly what i want the moveableframes to do lol. |
You're on the right track. Ok, bear with me if there are typos, still at work.
lua Code:
This is the simplest way to check your vars. |
you could say
Code:
local defaultTableList = { "not table[k]" means the value stored into table[k] can EITHER be nil or false. so if a user sets his setting to false, and you use not table[k], then his settings will be overridden each reload |
Oke ... I would say the point is this part:
Code:
for name, parent in pairs(GMoveableFrames) do It sets the table value for every hooked frame to nil. If the frame couldn't be hooked or if the frame doesn't exist (!) it doesn't set the table value to nil. Code:
local frame = _G[name] The point is, the three frames you find in you saved vars (GlyphFrame, LFGParentFrame, and InspectFrame) don't exist before the player actually uses them. The are created on demand. Other frames (my guess is all other frames ... but tested it only for PVPFrame which indeed exist) are created on load. That means the code snippet above clears the table, except the three non-existent (at least on PLAYER_LOGIN) frames. |
Additionally, if you are looking for a direct copy you can use
lua Code:
|
All times are GMT -6. The time now is 02:49 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI