Thread Tools Display Modes
06/12/16, 09:01 AM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Issue with multiple Saved Vars in 1 metafile

Hello,

In one of the project I have, I got multiple saved vars.

There declared as is :

Lua Code:
  1. ## SavedVariables: POSTMAIL_DEAMON DATAMINED_DATA DATAMINED_BOOKS DUMPING_DEAMON eideticReverse eideticHomonym

DATAMINED_DATA DATAMINED_BOOKS are a bit linked together.

DATAMINED_DATA is built by a function, no problem.


Then I got another function, which does this :

Lua Code:
  1. DATAMINED_BOOKS = DATAMINED_DATA

then DATAMINED_BOOKS is altered several times

When saving, changes are repercuted in both variables.

This first issue is easy to handle, because both variables (two arrays of hundreds of thousands of lines) are equal..




Another issue is with eideticReverse eideticHomonym

eideticReverse is linked to a slash command, the array is built.
eideticHomonym is linked to a another slash command, the array is built.

eideticReverse & eideticHomonym are in the same Lua file but each one got its own function they don't have anything in relation, except being in the same Lua file and the metafile.


When I run the function which build eideticHomonym, 1 column is written in eideticReverse variable and so the code is totally faked.


the possibilities for me are to change the metafile (remove one of the 2 vars) before executing code in order to avoid this, Or merge the whole data into one super array, like ZO_Ingame does.

If its a known bug, or something.

The var POSTMAIL_DAEMON is built from datamining since months, and I wouldn't lost it due to this issue ...

PS: I don't use the ZO_SavedVars object.
  Reply With Quote
06/12/16, 09:30 AM   #2
Randactyl
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 251
Lua Code:
  1. DATAMINED_BOOKS = DATAMINED_DATA

Just gives you another way to look up the table pointed to by DATAMINED_DATA.

If you want to make a copy of DATAMINED_DATA into DATAMINED_BOOKS and then do operations on it, use either ZO_ShallowTableCopy or ZO_DeepTableCopy. Iirc, the deep copy preserves any metatables while shallow only copies the actual data. (I think you knew this, just expanding for completeness).

As for the other issue, I'd have to monkey around with it to see for myself and I dont have time today
  Reply With Quote
06/12/16, 02:16 PM   #3
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Ayantir View Post
This first issue is easy to handle, because both variables (two arrays of hundreds of thousands of lines) are equal..
You may be hitting the hard limit of ~262k constants per file. It can be saved, but not loaded properly.
http://www.esoui.com/forums/showpost...5&postcount=33
http://www.lua.org/source/5.1/lcode.c.html#addk
http://www.lua.org/source/5.1/lopcodes.h.html#SIZE_Bx
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Issue with multiple Saved Vars in 1 metafile

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off