AceDB-3.0 not saving
This thread is similar to my previous one, but I just can't figure out why AceDB is not working correctly.
I have followed the AceDB Tutorial here like 5 times and have read others but can't get AceDB working correctly. https://www.wowace.com/projects/ace3...b-3-0-tutorial Currently I have this menu: It has toggles, sliders, dropdowns everything working nicely actually. Even the profiles tab works and i can see different profiles. (Like Realm, Default, Char etc.) But nothing saves correctly. After reloading or logging out NOTHING is saved. I have deleted the saved variables probably 10x now and tried restarting, logging out, reloading etc. Nothing seems to work. This is how the saved variables file looks like: Lua Code:
Which makes sense, the Menu in the screenshot is just filled with my default values. This is my Initialization: Lua Code:
If you want to see the full addon you can see it here: https://github.com/gempir/gempUI/blo...9a1/config.lua "gempDB" is my Saved Variables Variables references in the .toc file Code:
## SavedVariables: gempDB I even copy pasted this example https://wow.gamepedia.com/WelcomeHom...3_to_the_Party and tried it out and can't get it working in my current setup. Which makes me think I am loading the libraries wrong or something? I have no clue at this point. I'm running 0 addons besides my own addon so there is no interference with other libraries. Has anyone struggled in a similar way with AceDB? I've tried not using acedb and saving into gempDB directly in the getters/setters. This works without a problem, but I really would like the Profile solution of AceDB and not write my own Profile management. |
This has been mentioned before: AceDB does NOT write updated values to your saved variables file unless the user changes a setting from the default to something else.
If nothing has been changed from the defaults table, then nothing is written. Let's say you have this default table: Lua Code:
|
Yeah I totally get that and I've read that before aswell, but that's not my issue. My issue is I can't change anything and get it saved.
Like changing the default profile is a change from the defaults, so it should show up in the saved vars. But it doesn't and the ingame menu resets after a reload. |
So do the options actually work and affect the addon functionality? Regardless of whether they get saved.
Have you tried printing the contents of gempDB after changing something to see if it's "physically" written to the DB? |
Quote:
But gempDB itself stays empty besides the Boilerplate stuff, I've posted above. |
Okay, if gempDB the table is populating, and changing settings in game actually does stuff, yet reloading the UI and exiting out of the game do not write to disk, then you probably have a file permission issue.
Assuming you use Windows, is your game installed in some variant of Program Files\World of Warcraft? If so, move the game to a neutral folder, like C:\ or C:\Blizzard\World of Warcraft. Windows is notorious for not letting the Program Files path have write privileges. You can further test this by installed a totally different AddOn, changing its settings, then either reloading the UI or exiting out and checking the saved variables file. If nothing is written, then you know for sure. |
Quote:
Also my WoW is here: C:\Games\Blizzard\World of Warcraft not in "Program Files" BUT I did not mean gempDB Table is populating. the self.db (internally from AceDB) Table is Populating, not gempDB. gempDB looks like this (even when changing a lot of settings): |
As an experiment, temporarily remove all .ace from your G table, so it reads like G:OnInitialize, G.db, etc.
Further, I suspect (but can't confirm) that the following line is the root of your issue. Assuming that your posted code is the first Lua file loaded that isn't a localization file or a library, the tables G and V do not exist as far as AceDB is concerned, but F does. It would greatly help if you posted a zip of your addon for downloading and testing. What are the full names for F, G, and V? What do they represent? Single letters are beyond vague. Code:
local F, G, V = unpack(select(2, ...)) |
Quote:
I saw something similar in ElvUI and just started copying it in my own way, guess it doesn't make a ton of sense and I'm just using it as a dirty hack currently. I start all my lua files with that btw. This explains it a bit: Lua Code:
You can download the Addon via github https://github.com/gempir/gempUI/archive/master.zip just rename the folder inside the zip to gempUI |
This construct makes no sense. '...' represents the arguments passed to every file loaded in your addon.
There are only 2 arguments. The first is the name of your addon. And the second is a table unique for your addon. So you should only have one line. It should look more like this Code:
local name, ns = ... |
The line does make sense.
Lua Code:
Means it returns all arguments after 2 (including 2) so only "ns" in your example. Unpack then turns the table of core into 3 variables into F,G,V Lua Code:
So it's basicly the same as your example but ignores the name of the addon. |
Quote:
And two for the addon table (ns, core) So for me it does not make sense to have different names for the same variables. And as you say select will always unpack core so why not use it? It would highly increase readability. |
The name core is only ever seen in the main lua file. All others just know about F, G, V which is kinda nice IMO. but I agree readability could be improved. It takes a minute to understand what the hell unpack, select, etc. do
But sadly it's not having an impact on Ace3, I've tried using a local variable for Ace instead of G.ace but I'm having no luck with saving variables either. |
UPDATE!
Okay so after debugging this for days now I've finally figure out the problem. Somehow Ace3's OnInitialize function does not work as expected. The official docs show this: Lua Code:
"AceDBExampleDB" is the saved var from the .toc file. I've done the same with my "gempDB" but I finally found out that it's nil at this point of the loading process. I hacked together this quick fix: Lua Code:
and VOILA my config now saves correctly after reloading. The only Idea I have is that AceDB listens to the wrong ADDON_LOADED event? But I'm assuming the first argument of :NewAddon dictates the addon name, and that's what I have. Lua Code:
So. Anyone an Idea what's going on? Should I maybe open an issue on their wowace page? |
Quote:
Stop looking at ElvUI's code. Just. Please. Stop. Delete all knowledge of it from your brain. Never look at it again. I cannot stress this enough as it is possibly the worst example of how to write and maintain a full UI, and new Lua authors get lost in trying to understand. I don't have time right now to write up a brief and correct way to write your GempUI, but I will do my best when I do have time. When I do write it up, I shall endeavor to document it as clearly as possible. |
Quote:
I appreciate any tips. |
I don't have any experience with the ElvUI source, but in general it might be better starting with a simpler example.
I had a look at the Ace3 source, and the logic behind OnInitialize was a bit confusing to me, so I don't know what could've gone wrong there. I think you can definitely submit a ticket, but first you should narrow your code down. Make as simple as possible an example of the OnInitialize method not firing. |
I think this is a bit too focused on ElvUI here. All Im doing is using wow addon namespace with a table.
|
Do you really need Ace-Addon? If you dont use any other function from this lib you can just leave it alone and directly register ADDON_LOADED like you do in OnInitialize. Every ACE-Lib is standalone. e.g. I use, Ace-Db, Ace-Config but never Ace-Addon.
For my addons I do it this way ... where childName is the addon name and addon is the namespace-table, defaults is the table where defaults are defined. Lua Code:
|
I wrote two test-addons and both work as they should. The first without AceAddon and the second with.
Lua Code:
Lua Code:
Lua Code:
Lua Code:
You can find them in the WoWI-SVN |
All times are GMT -6. The time now is 06:20 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI