SavedVariables not writing table
Hey folks,
I'm fairly new to lua and WoW addon development in general so hopefully this is a simple issue. I have the following code as the only lua file loaded by my addon. Code:
local REGION_NAMES = { However, when I open the SavedVariables file from my local disk, I see: Code:
|
I may be wrong here, but I don't see the variable referenced in the global namespace. I am under the assumption that you have to at least define it in the global namespace first, before making any updates to the variable with local functions, in order for it to be saved properly.
I may be completely wrong here, but its how I do it. Also, just double checking you do have the variable set up to be saved in the .toc file with the ## SavedVariables: variablename line correct? |
Thanks for the quick reply!
Quote:
It's in my .toc file: Code:
## SavedVariables: ArmoryHubExportData |
Like i said, that part may have been wrong, so just ignore it.
My next guess would be that you are running the saveWardrobe function on logout, which calles the getWardrobe function, and it may be updating the table with empty data due to the timing??? Try commenting out the on logout portion of the code, and only have it update when you run the slash command, logout and see if that fixes it. |
Oh wow, that was it! It seems to be working now.
I guess when the log out event is emitted, the transmog API is returning nothing? Is there a way around this? Maybe a "pre log out" event of some kind? |
There is almost never any reason to expressly register and use PLAYER_LOGOUT to write your saved variables, as the game automatically writes SVs to disc during that event, meaning you don't have to do it.
The only reason I can think where someone might do it is if they use local references to longer SV tables and want to re-map the SVs to the local references. Usually nobody does this as it makes debugging a lot more difficult. You can also use PLAYER_LOGIN to create or verify your SV table instead of ADDON_LOADED, mostly because PL only ever fires once and you don't have to parse the results until your addon is found. |
Thanks for that information!
The only reason I introduced the slash command is because I cannot seem to load the transmog data from the start. This code: Code:
function frame:OnEvent(event, arg1) Is there some event I can listen to that will fire once certain APIs (such as transmog) are ready? |
Then the information may not be available yet when your addon loads. All information about your character (presumably including what transmogs you know) should be available by PLAYER_LOGIN.
|
Awesome, this works.
Thanks all so much! |
All times are GMT -6. The time now is 08:24 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI