Exclude data from save game?

Place to get help with not working mods / modding interface.
Post Reply
suan2
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon May 22, 2017 1:41 pm
Contact:

Exclude data from save game?

Post by suan2 »

I wrote a mod which stores quite a lot of data for each entity it in the game. When the factory becomes big (say 10k entities) it becomes slow to save and load the game. Around 20 seconds for 10k entities. The save file is not too big, 2 MB compressed, the "script.dat" inside the save file is 26 MB for the 10k entities.

Most of the data my mod keeps in memory are easy to recalculate so not necessary to save into the save file. Is there any way to exclude some data from the save game? I'm looking for something similar to the "transient" keyword in Java.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Exclude data from save game?

Post by eradicator »

Anything saved to the global table named "global" (i.e. _ENV.global) is stored into the savegame. All other variables are not. Recalcuation is only a good idea if it happens distributed over many ticks though (just warning you to not try to recalculate a huge bunch of stuff right after loading :P).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”