Egor-Skriptunoff/LGS_extension

Global Table G for sharing Data across profiles

cpbentley opened this issue · 3 comments

It is not really an issue, but more of a feature request.

I am using the Persistent Table D already. I have many different LGS profiles, one for many different applications. Code, Browser, Telegram etc etc.

Persistent Table D stores data for a single profile. That's good.

Could we have a Persistent Table G that stores data for all profiles? A profile reads/saves its own Table D and it reads/saves the Table G that is read/saved by all profiles.

It will allow us to share data across profiles. Or maybe there is another way already?

If multiple profiles share the same D_filename then they share the table D.

So instead of

D_filename = "D_for_profile_name.lua"

you can write in each profile script

D_filename = "D_for_all_profiles.lua"

If you need both global and profile-specific tables, just make a shared D table and use its subtables for profile-specific data:

D.profile1 = {...}; D.profile2 = {...}; D.shared_data={...}

Please note that total amount of data in D must be not more than 50-100 KBytes. Otherwise it would take more than 1 second to serialize the data, and LGS would crash.

thank you for the pointers.

I managed to pass state.

As a side node, I noticed that one profile is not able to read or write the D table. When I create a blank new profile, it works. When i create a new profile based on that one profile, this new profile cannot read the D table either.
EDIT: Do not forget to add the D_SAVER macro.. that's why!

Work around is to delete that one. And transfer the macros to a fresh new one.

Sorry, no idea.