03/25/15, 09:58 AM | #1 |
Saving hidden state
Hello all,
I want my addon to be set hidden in the options. I also want this to be saved in the savedVariables. However I constantly keep getting Code:
user:/AddOns/RaidScore/RaidScore.lua:47: attempt to index a nil value stack traceback: user:/AddOns/RaidScore/RaidScore.lua:47: in function 'func' user:/AddOns/CombatCloud/libs/LibAddonMenu/controls/button.lua:61: in function '(anonymous)' Lua Code:
Last edited by Woeler : 03/25/15 at 10:32 AM. |
|
03/25/15, 10:33 AM | #2 |
Edit:
@Woeler If you edit your sourcecode in the post after we are already answering it... this won't really help :-( I was just wondering why I have a different source code that I've checked for you, then the sourc code that you have in your post NOW. All of sudden variable names changed and source lines were commented? My answer was: Check your optionsData where you have set your variable "hideScore": Lua Code:
1. hideScore here is a global variable because you did not define it as local 2. Or do you want to change the variable RS.hideScore and you just forgot the "RS." ? For option 2 it should look like something like this: Lua Code:
In addition your saved variables table/array is using the variable Scores in your options menu, if you press the "save" button: Lua Code:
But you have initialized it with the default saved variables data local defaults to be named "HideScores": Lua Code:
So I assume it should look like this for your button to save the data: Lua Code:
As a better explanation: 1. You define some default data for the saved variables which will be loaded if the saved variables do not have any stored data (1st time your addon loads e.g.). You haev defined them in your table "defaults": Lua Code:
Lua Code:
Your addon will load all data from the stored file and if nothing is found it will use the content of your variable "defaults" as the default values. 3. In your settings you will be able to change values and then update your saved variables with the updated values. You can do this directly by changing "savedVariables.HideScores" e.g., of like you do by changing a helper variable table "RS" witht he entry "hideScore", and afterwards assign the content of your helper variable to your "savedVariables" table. 4. If your game client is logging out, doing a /reloadui or exits the variable "savedVariables" of your addon will be written to the .LUA file on your local harddrive. The harddrive's filename will have the same name like your addons does and will be stored inside the SavedVariables folder in "c:\users\<your windows username>\documents\Elder Scrolls Online\live (or liveeu)\SavedVariables\". Inside this .LUA file you will find the stored settings in the array structured that you have specified in your addon's .TXT manifest file in this statement: Code:
## SavedVariables: <your saved variables name> You'll find "offsetX", "offsetY" and "HideScores" in there with their values. Last edited by Baertram : 03/25/15 at 10:53 AM. |
|
03/25/15, 10:41 AM | #3 |
savedVariables is declared after the options. In LUA the order is important. In line 47 savedVariables is still unknown.
|
|
03/25/15, 11:22 AM | #4 |
Your solutions combined did it! Thanks for the help guys!
Last edited by Woeler : 03/25/15 at 11:32 AM. |
|
ESOUI » Developer Discussions » Lua/XML Help » Saving hidden state |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|