Mod-settings.dat file editor (in C#)
Mod-settings.dat file editor (in C#)
For anyone looking to build their own editor for the mod-settings.dat file I made this quick-and-dirty C# editor example: https://www.dropbox.com/sh/uscmj9y3cjfw ... 7fxga?dl=0
If you want to get ahold of me I'm almost always on Discord.
Re: Mod-settings.dat file editor (in C#)
why not include it in the build?
Doesn't need to look fancy.
Doesn't need to look fancy.
Re: Mod-settings.dat file editor (in C#)
Because the game already comes with a built in settings editor: itself.steinio wrote:why not include it in the build?
Doesn't need to look fancy.
If you want to get ahold of me I'm almost always on Discord.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Mod-settings.dat file editor (in C#)
I thought the whole point of having an external settings editor was to fix cases where borked settings prevent the game from starting up in the first place (i.e. because a setting triggers an if-clause that leads to bugged code).Rseding91 wrote:Because the game already comes with a built in settings editor: itself.steinio wrote:why not include it in the build?
Doesn't need to look fancy.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Mod-settings.dat file editor (in C#)
Yeah, I was actually going to write a setting that could have very easilly induced this state, instead I sat down and thought about it, and changed the setting to something else that performs a similar job, but can't induce this state.eradicator wrote:I thought the whole point of having an external settings editor was to fix cases where borked settings prevent the game from starting up in the first place (i.e. because a setting triggers an if-clause that leads to bugged code).Rseding91 wrote:Because the game already comes with a built in settings editor: itself.steinio wrote:why not include it in the build?
Doesn't need to look fancy.
Before changing the .json to a .dat, I would have used that previous possibly dangerous setting.
Last edited by bobingabout on Tue May 01, 2018 8:16 am, edited 2 times in total.
-
- Long Handed Inserter
- Posts: 66
- Joined: Sun Aug 06, 2017 9:42 am
- Contact:
Re: Mod-settings.dat file editor (in C#)
i keep one or two backup copies of the modsettings.dat file in a folder or zip file now that the devs made it unfriendly to text editors.
Re: Mod-settings.dat file editor (in C#)
The built-in settings editor isn't accessible when a startup setting is causing the game to not load. Being able to edit the settings outside of the game avoids the need to relaunch the game yet another unnecessary time.
Re: Mod-settings.dat file editor (in C#)
Guess who just learned this lesson the hard way...
*cough*
Spoiler: Me
I'm pretty shocked by the lack of recourse here. Is there no way to trigger defaulting the settings for ONE mod? We're stuck nuking everything or writing our own external editor?
I'm not mad Wube... I'm just... disappointed.
Would be great if you could create an empty file with the mod name or something to cause the game to default/reset a specific mod's settings and consume the file. This all-or-nothing approach to mod settings is something a AAA studio would do
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Mod-settings.dat file editor (in C#)
Not even the in-game settings menu can do that. Something i've wanted for a long time...
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Mod-settings.dat file editor (in C#)
FYI I've updated the tool for 17.0, looks like another byte was added after the version blob causing the deserializer to get confused. I've also noticed that reserialized options are not binary equivalent, looks like there was a blob of 0x010100 (3B) that was converted to 0x00000000 (4B), not sure why.
Also, I added command line options so that you can reuse the code for compiling/decompiling the .dat file without having to recompile the code as well.
Also, for some reason the zip file has two different cases for the main code directory (breaks on case sensitive filesystems, but minor fix)
With Rseding's permission I can upload all of this to github.
Also, I added command line options so that you can reuse the code for compiling/decompiling the .dat file without having to recompile the code as well.
Also, for some reason the zip file has two different cases for the main code directory (breaks on case sensitive filesystems, but minor fix)
With Rseding's permission I can upload all of this to github.
- CobaltEcho
- Burner Inserter
- Posts: 12
- Joined: Sun Mar 05, 2017 4:16 pm
- Contact:
Re: Mod-settings.dat file editor (in C#)
Did you ever upload this?kevok wrote: ↑Sun Jul 21, 2019 10:09 pm FYI I've updated the tool for 17.0, looks like another byte was added after the version blob causing the deserializer to get confused. I've also noticed that reserialized options are not binary equivalent, looks like there was a blob of 0x010100 (3B) that was converted to 0x00000000 (4B), not sure why.
Also, I added command line options so that you can reuse the code for compiling/decompiling the .dat file without having to recompile the code as well.
Also, for some reason the zip file has two different cases for the main code directory (breaks on case sensitive filesystems, but minor fix)
With Rseding's permission I can upload all of this to github.
Re: Mod-settings.dat file editor (in C#)
I don't mind if someone else wants to take over the code/do what ever with it.
If you want to get ahold of me I'm almost always on Discord.
Re: Mod-settings.dat file editor (in C#)
So I rewrote this app as a nodejs module (Still needs work). I noticed that in your code (and the wiki docs) is that reading and writing strings is handled differently from how Factorio actually does it. Perhaps this is just differences between Factorio versions 0.16 (that your app was originally written for ) and 0.17? Kinda like the extra always false boolean value added in 0.17 after the map version?
First Issue:
You are suppose to write TRUE for the any-type flag when the property type is a string. In practice the any-type flag is always written as false by Factorio. So I am following suit with Factorio and always writing false.
Second Issue is much the same
When writing strings you write a boolean for if the string length is 0 or not and then skip writing the rest of the string value data out when it is zero. What I actually discovered is that is factorio always writes false then writes the rest of the string value even for a zero byte string. This one really tripped me up for a several hours.
Once I did both of these "corrections" my nodejs script saves mod-settings.dat bit-for-bit identical to the original mod-settings.dat
[edit]
Is is possible to partially parse the game save? Just enough to determine the mods installed, mod versions and mod settings?
Haven't taken a crack at it but an initial look-see is promising as level.dat seems to operate much like mod-settings.dat at least before the actual level data appears.
Would it also be possible to get future factorio versions to report the startup modsettings to the matchmaking API? Would be nice to swap mods to match the server and the mod-settings all in one go instead of having to restart twice.
First Issue:
Code: Select all
//FileName: JsonUtil.cs
private static void WritePropertyTree(Serialiser output, JToken token)
{
PropertyTreeType type = ParseTokenType(token.Type);
// Type
output.Write((byte)type);
// Any-type flag
output.Write(type == PropertyTreeType.String);
Second Issue is much the same
Code: Select all
//FileName: Serialiser.cs
public void Write(string value)
{
Write(value.Length == 0);
if (value.Length == 0)
return;
Once I did both of these "corrections" my nodejs script saves mod-settings.dat bit-for-bit identical to the original mod-settings.dat
[edit]
Is is possible to partially parse the game save? Just enough to determine the mods installed, mod versions and mod settings?
Haven't taken a crack at it but an initial look-see is promising as level.dat seems to operate much like mod-settings.dat at least before the actual level data appears.
Would it also be possible to get future factorio versions to report the startup modsettings to the matchmaking API? Would be nice to swap mods to match the server and the mod-settings all in one go instead of having to restart twice.
- BlueTemplar
- Smart Inserter
- Posts: 3212
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Mod-settings.dat file editor (in C#)
For some use-cases, it might be easier to just uncompress the mods, change their default settings to what you want -
(bonus : with a script you could check what settings you have changed compared to default - which can NOT be seen in game !)
- and then just delete mod-list.json and mod-settings.dat whenever you have a mod/settings caused crash.
(bonus : with a script you could check what settings you have changed compared to default - which can NOT be seen in game !)
- and then just delete mod-list.json and mod-settings.dat whenever you have a mod/settings caused crash.
BobDiggity (mod-scenario-pack)
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Mod-settings.dat file editor (in C#)
Changing the default values for a setting inside a mod does not affect the value of that setting if the mod has ever been loaded before. Pre-existing values in mod-settings.dat are (logically) always preferred.BlueTemplar wrote: ↑Mon Jan 20, 2020 1:57 pm For some use-cases, it might be easier to just uncompress the mods, change their default settings to what you want -
Edit: Oh, you said "and then delete mod-settings.dat". But that would a) reset settings for all mods and b) imply that the mod crashes with default settings, in which case you should post a bug report so everyone gets the fix.
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.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
- BlueTemplar
- Smart Inserter
- Posts: 3212
- Joined: Fri Jun 08, 2018 2:16 pm
- Contact:
Re: Mod-settings.dat file editor (in C#)
I'm using the "default" settings in the extracted folder as custom ones.
EDIT : Some context, with one use-case : random seeds :
viewtopic.php?p=474162#p474162
EDIT : Some context, with one use-case : random seeds :
viewtopic.php?p=474162#p474162
BobDiggity (mod-scenario-pack)
-
- Manual Inserter
- Posts: 1
- Joined: Thu Jul 15, 2021 1:39 pm
- Contact:
Re: Mod-settings.dat file editor (in C#)
Hi Rseding91
I've your project to support Factorio 1.1 with option to select mod-settings.json or mod-setting.dat
Here the project: https://github.com/MatrixDJ96/Mod-Settings-Converter
I've your project to support Factorio 1.1 with option to select mod-settings.json or mod-setting.dat
Here the project: https://github.com/MatrixDJ96/Mod-Settings-Converter
Last edited by mattyro96@gmail.com on Thu Jul 15, 2021 1:43 pm, edited 1 time in total.