Page 1 of 1

Transfer data between games

Posted: Mon Dec 05, 2022 12:19 pm
by Theis
Is it possible for a mod to store some data in game A, and then for the mod to load that data in game B?

For instance, you have a time trial mod. Where the goal is produce the most iron-plates in 30 minutes.
So to compare, you would first run the time trial and produce 1020 iron-plates.
Then next time you try you produce 1312 iron-plates.
Is there anyway for the mod to compare those two values and print the information of how much you have improved?

I can see it is possible:
- to read information from settings.global, but it does not appear possible to write data there.
- to write data to script-output, but I can't find any methods reading it.

I understand that this might be impossible, but I would like to be sure.

Re: Transfer data between games

Posted: Mon Dec 05, 2022 12:44 pm
by Xorimuth
It is possible with the use of an external program running outside of factorio at the same time. Data out is done by write_file which you already found. Data in must be done using RCON: https://lua-api.factorio.com/latest/LuaRCON.html
This page doesn’t seem to explain very much and I can’t find the page that does right now. But it is definitely possible for mods to receive RCON messages from external programs.

Re: Transfer data between games

Posted: Mon Dec 05, 2022 4:16 pm
by Theis
Okay that sounds cumbersome to say the least, but I guess it is better than nothing.
I have absolutely zero experience with RCON, so let me try to wrap my head around it.

I would then need to setup an RCON client (maybe https://github.com/mark9064/factorio-rcon-py)
I would then need to launch Factorio in RCON server mode, and connect the client and the server.
Then I have a path to send messages out of Factorio and console commands into Factorio.
Then I just need to use the messages outside factorio to write ....

Re: Transfer data between games

Posted: Tue Dec 06, 2022 11:50 am
by Bilka
You can write to your own mod settings: https://wiki.factorio.com/Tutorial:Mod_ ... n_settings. However, this is only useful for transfer of data between saves if the player has the setting "Use different mod settings per save" turned off.