I've got a rather huge script that manipulates a lot of data. It's currently got probably around 300-400 arrays and variables related to different potions/ingredients and their effects, user settings related to those effects, etcetera. But this script also has a lot of functions and events that manipulate that data, and sometimes the data needs to be accessed by other scripts too.
I'm looking for a good design method to use which will make accessing all this data as quick & efficient as possible. One of the main reasons I'm asking is that I sometimes notice in my MCM menu a lag of 2-3 seconds before an option will respond to user clicks, which I think is caused because the MCM script is asking for the value of a boolean property from my main data-storage script, which is also probably already bogged down in a dozen or more other multiple competing threads relating to its own functions and events, so I think it takes awhile before the MCM script is given access to the info it is asking for. The MCM is just one example, there are other scripts that also try to access this storehouse of data that need to be able to get the data as fast as possible.
I'm wondering what a better way to manage my data would be.
One thing I've been considering: moving all my data into a script with no functions whatsoever, and just have all the other scripts grab the data from this functionless script (which will then hopefully never be busy to prevent the data being accessed). A question I have related to this option, though, is whether threads lock a whole object or just a script (i.e., would I need this data storage script to be attached to an entirely different quest to avoid being affected by threads working on other scripts on the same quest?)
The other thing I considered is, since 80% of my data is in arrays already, maybe I could just create local array variables in each script that point to the same array. And I could convert some of my other variables that aren't currently arrays into arrays (for instance, my booleans into boolean arrays with only one member - which would then allow me to access and manipulate the same data directly through different locally defined arrays in the various scripts).
Maybe there are other options I haven't thought of too, so I was hoping someone with more experience with this kind of thing could offer some suggestions. Thanks for listening!