Need help loading SavedVariable setting.
I searched around and I have tried a dozen things but somehow, I can't get it to work.
I can get the value 1 or 3 saved, but somewhere with reading it back, it goes wrong but I am unsure why. Here is the AddOns code: Code:
Code:
WorldMapFrame.BlackoutFrame.Blackout:SetAlpha(0) And here is the .toc. Code:
Code:
The savedvariable contrains either "SimpleMap = 1" or "SimpleMap = 3". Somehow the following doesn't trigger: Code:
if SimpleMap == 1 then I tried "AddOn Loaded" events and saying that variable "SimpleMap = SimpleMap" so that the value is loaded but nothing. Clearly SimpleMap isn't being assigned with the SavedVariable value. Can anyone help me? It feels like the solution should be simple but I never made a WoW AddOn before so a bit difficult for me! |
https://wow.gamepedia.com/Saving_var..._game_sessions
Quote:
|
Quote:
What am I missing? |
The addon loading process loads the file(s), executes the stuff that is placed in the main code-flow and after that only events can trigger execution of your code.
Any code that is executed before ADDON_LOADED with the argument of your own addon cant access your SV. You have to listen for this event. And only after this event occurs make sure it is fired for your addon and setup your stuff after that. |
Lua Code:
|
Thank you both for the suggestions, but even with my whole script inside the addon_loaded event (with checking for my addon name), it still doesn't work.
Hell, my whole AddOn just doesn't work at all when I do it inside/after the addon_loaded event. It was worth a shot. |
SavedVariables are initially nil so if they require meaning other than that then you need to initialise them first time in.
PLAYER_LOGIN event Lua Code:
|
Or, an edit to Fizzlemizz's code (that is more relevant to what you are learning):
Lua Code:
https://wow.gamepedia.com/AddOn_loading_process |
I like PLAYER_LOGIN because you don't have to check for an addon name, it only fires once and that one time after all addons have loaded and before PLAYER_ENTERING_WORLD. Then again, I'm lazy :)
|
Thanks all for the help. I managed to get it working with the "PLAYER_LOGIN" event!
|
All times are GMT -6. The time now is 05:58 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI