08/03/15, 08:28 PM | #1 |
|
Issue with saving
So what I wanted to accomplish was to build a table like so:
Code:
function buildatable(saveType) local temptable = {} local numitems = getNumItems() -- inconsequentially named function, -- this refers to a function that simply outputs the number of different -- items in the array I am attempting to save the values of for item = 1, numitems, 1 do -- here I assign things to the temptable and iterate through with more for -- loops and more table declarations like temptable[item].subitems = {} -- Eventually this becomes a very large multi-dimensional array of data. end if saveType == "Global" then myGlobalVarReference.table = temptable -- this does not work else myPerCharacterVarReference.table = temptable -- this also does not work end end I have little time today but I thought of a decent idea to instead of passing the variable saveType to call this function from within a function and pass the reference to which table to inject this data into into. Is that a feasable option? something like Code:
function beforebuildatable(saveType) if saveType == nil then saveType = myPerCharacterVarReference.saveType end if saveType == "Global" then buildatable(myGlobalVarReference.table) -- use global reference else buildatable(myPerCharacterVarReference.table) end end function buildatable (table) -- use same code as above but -- instead build the table inside the referenced table instead of injecting Note: I have really shorthanded all of this, but I believe that the basic concept can be easily read (correct me if I'm wrong) I do not have access to the real code at this time. |
08/04/15, 06:25 AM | #2 |
I don't know if I understood you right but here is some code which should work to store a deep table inside your addon's SavedVariables:
Lua Code:
|
|
08/04/15, 01:14 PM | #3 | ||
|
I'm not sure what you are trying to accomplish.
If you don't know how to use saved variables:
Warning: Spoiler
Lua Code:
## SavedVariables: savedVariableTable version: version number for your saved variables namespace: an optional namespace (it just creates another separate table IN your saved var table) defaults: Default table holding default saved var values profile: Creates a separate table in the the saved var FILE (not in the saved var table, see below for profile example) displayName: is the account name characterName: duh But unless you want something special you don't need to provide all of those options, just the: savedVariableTable & versionNumber (although a default table with default saved variables will most likely be wanted) anything you don't need just make it nil. If you leave the namespace nil (most addons do) it will use "Default" as the namespace. Lua Code:
With that code you can access the saved variable data with: CharacterSpecificSavedVars & AccountWideSavedVars. Just add items/tables/whatever to them as you wish and the game will handle reading/writing the information to the file: Lua Code:
Either way my guess is that it is probably saving, just not where you want or your not accessing it correctly afterwords.
Warning: Spoiler
It looks like from your code, the data should be saved here (saved variable file): Lua Code:
Lua Code:
If for some reason your trying to separate this information your trying to save from the rest of the saved variable data, you could add a profile like this:
Warning: Spoiler
Lua Code:
New saved var file with profile table: Lua Code:
Last edited by circonian : 08/04/15 at 01:19 PM. |
||
08/05/15, 02:02 AM | #4 |
|
Strange
Seems like the way I was injecting the data should have worked by what you guys are saying. I have since used the method I talked about in my first post to pass the saved variables table as an argument to the function. It works well for me but this is some great information!
To clarify that my table wasn't injecting I did reload the ui then check my saved variables lua. To my disappointment there was no information from the table inside. After simply changing to a hard-coded build into the saved variables tables I was shooting for it did work wonderfully, populated with all of the expected data. I'll definitely read through everything you guys replied with a few times. Glad to see there's such a helpful community here! Also to clarify, I was simply having trouble getting that table into my saved variables. What I wanted to end up with: Lua Code:
acting the same as Lua Code:
But instead this does nothing for me. Maybe I did something wrong. :/ Last edited by Talen-Shei : 08/05/15 at 02:58 AM. |
08/05/15, 03:00 AM | #5 | ||
Wandamey
Guest
Posts: n/a
|
could you post what you wrote in you addon manifest (.txt file in your folder)
and how you defined your savedvars first with ZO_SavedVars:New... please? it'll be easier to see what went wrong.
Last edited by Wandamey : 08/05/15 at 03:54 AM. |
||
Wandamey |
08/05/15, 06:33 AM | #6 |
I guess there are different ways to achieve the difference between account wide and cahracter based SavedVariables, yes.
The one solution I'm using is working well and performant so I didn't think about changing the "running system" |
|
08/05/15, 02:23 PM | #7 | |
|
Lua Code:
I don't understand why anyone would do different :P The only thing I'm struggling with at the moment is maintaining the saved variables. I can't seem to keep them up-to-date. say I have a value x containing table {x,y,z} and to the and of that I want to append the variable a. I would do table.insert(x,a) and the value a would become the fourth value of the table x. But let's say that table x is in my saved variables as such: Lua Code:
on uireload the information is there, but when attempting to access through LAM2.0 it is invisible data! do I simply need to refresh the data in LAM2.0? to clarify LAM2.0 will also recognize the new information as being a part of the table when I reload the ui and it works beautifully. It's just same session data changes that seem to never happen. LAM docs are also hard to find for some reason. Note: I do have this on my panel registerForRefresh = true, but I would like to be able to manually refresh this when I change data since it seems to be unreliable in my use case. To further clarify, I am not having trouble changing the setting but the available choices on a dropdown menu item. Lua Code:
Last edited by Talen-Shei : 08/05/15 at 02:27 PM. |
|
08/05/15, 02:42 PM | #8 |
|
Reading the other posts I now realize although I offered information, I didn't actually offer a solution:
Warning: Spoiler
Lua Code:
One other thing to note is that in these: Lua Code:
Lua Code:
Lua Code:
As the addon version number increases I just change the CODE_VERSION. If the saved variables need to be wiped due to addon changes, then increase the SAVED_VAR_VERSION...and don't define them right next to each other (one line right after another), you'll end up accidently changing the wrong one by mistake and wiping everyone's saved vars |
08/05/15, 05:41 PM | #9 |
|
Thanks!
Thanks for the tip circonian, I'm actually using the version number currently to quickly wipe my saved data to start from scratch during testing to ensure that everything is working as expected and nothing has been broken.
Also the change that you suggested is really just a rename. As you can see from the post prior I actually did declare those in my initialization function, again, for some reason it just didn't work for me. |
08/05/15, 06:27 PM | #10 | |
You can add a reference name to the options table and then call the UpdateChoices method. Lua Code:
Lua Code:
|
||
08/05/15, 06:41 PM | #11 |
|
|
08/05/15, 06:58 PM | #12 |
|
To add to what sirinsidiator said:
Lua Code:
Make sure you realize that if you call: Lua Code:
But if you had defined the table like this: Lua Code:
If you want to change the choices used (instead of using whatever you defined with choices = ....) you can pass a table to the UpdateChoices function. For example if I had two different tables of choices & depending upon some other setting I want to show different choices in the dropdown. You could initialize it with: Lua Code:
Last edited by circonian : 08/05/15 at 07:02 PM. |
08/06/15, 03:14 AM | #13 | |
|
@sirinsidiator, Thank you so much! And while I am at it I must say, why is this not in the examples?! I guess I would have realized it if I actually looked at the comment block at the top of LAM's dropdown.lua >.> dropdown.lua:
Warning: Spoiler
Lua Code:
And thanks yet again Circonian for the details on how this works! |
|
08/06/15, 03:47 AM | #14 |
That's because I haven't yet had the time or motivation to improve the documentation since I have taken over LAM.
|
|
ESOUI » Developer Discussions » Lua/XML Help » Issue with saving |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|