Is there any way to save the data of the table permanently

Place to get help with not working mods / modding interface.
Post Reply
sdgmlj
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Is there any way to save the data of the table permanently

Post by sdgmlj »

I mean, when I start a new game, I automatically read the data of the table

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1207
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by FuryoftheStars »

What table?

There is the "global" table available to each mod that is saved and load from the save file. You can store things you need need to persist there. There are some limitations, though. There was a discussion about it not too long ago: viewtopic.php?f=25&t=102241

(But seriously, what table?)

sdgmlj
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by sdgmlj »

FuryoftheStars wrote:
Fri May 20, 2022 4:31 am
What table?

There is the "global" table available to each mod that is saved and load from the save file. You can store things you need need to persist there. There are some limitations, though. There was a discussion about it not too long ago: viewtopic.php?f=25&t=102241

(But seriously, what table?)
I can't understand those discussions. The table I'm talking about is the custom global table of my mod, which is used to save some setting data of my GUI, for example:

Code: Select all

global.my_mod = {}
global.my_mod.setting1 = true
global.my_mod.setting2 = true
..........
The values of these tables can be modified in the game. I want to automatically read the modified values when starting a new game, but now the result is that they can only be saved in each game. When starting a new game, they will be cleared. How can I save these tables?

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1207
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by FuryoftheStars »

The global table cannot be used between different save files.

Any “settings” of that nature that you need to persist between different games, you’ll need to use actual settings for (https://wiki.factorio.com/Tutorial:Mod_settings). Note that the user will need to set these from the main menu in order for changes to persist. Changing from within a running game will affect that game only.

sdgmlj
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by sdgmlj »

FuryoftheStars wrote:
Fri May 20, 2022 5:23 am
The global table cannot be used between different save files.

Any “settings” of that nature that you need to persist between different games, you’ll need to use actual settings for (https://wiki.factorio.com/Tutorial:Mod_settings). Note that the user will need to set these from the main menu in order for changes to persist. Changing from within a running game will affect that game only.
Can the value of "setting" be reversed? For example:
settings.global["my-mod-setting"].value = global.my_mod.setting1
In this way, I can add some hidden setting options to save these settings

FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 1207
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by FuryoftheStars »

Yes, but similar to a player trying to change the setting during a running game, (as far as I know) it will not persist between different games/saves.

sdgmlj
Fast Inserter
Fast Inserter
Posts: 123
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Is there any way to save the data of the table permanently

Post by sdgmlj »

FuryoftheStars wrote:
Fri May 20, 2022 1:21 pm
Yes, but similar to a player trying to change the setting during a running game, (as far as I know) it will not persist between different games/saves.
Thank you. I see

Post Reply

Return to “Modding help”