Save File Fixer (Python) [Old] [Reference Code]

Started by Vas, July 26, 2015, 05:31:33 AM

Previous topic - Next topic

Vas

This was once made for my hydroponics mod when I changed the def name of something in the game and I needed to repair my game files so that you don't need to start a new map to continue playing.  I leave this here as a reference now, so other people can use the code if they know python to change how it works and they can change things in their mods and include a copy of the save file fixer too.

This python script is highly intuitive and is easy to alter for your needs, I put variables in that let a mod author change only stuff in the top few lines to make the script work for his needs.  It asks the user all sorts of questions and tries to predict the location of the game saves even.  Should work on all platforms but I'm unsure since I've only ever tested on Windows.

Seems my tool hasn't gotten much recognition at all though as I do see some mods that say "incompatible with current saves" when this file could fix their issue.  :P  But anyway.



I changed a defName in one of my mods (Hydroponics), and wanted to make sure users could upgrade their save file to be compatible with the new update.  So I spent a while with a few friends working on a script and thought it'd also be nice to make it intuitive and intelligent, with plenty of comments to help people edit and tweak it all they like.

So here it is!
Dropbox Download - Cause those A-holes deleted public folders...
Paste bin

If you want to make it work with your mod so you can change def names, simply read the comments in the script.  Short version; you only need to replace the first word with the word you want replaced and the second word with the word you want to replace it with, in the lines 22 to 28.  You can copy the line 28 and add more after if you need to replace more.

Preview of area I'm talking about;
replacements = [
    ('HydroponicsBasinModularPotent', 'HydroponicsBasin4S'),   # Enter the words you want replaced
    ('HydroponicsBasinModularFertile', 'HydroponicsBasin3S'),  # in these slots.
    ('HydroponicsBasinModularRich', 'HydroponicsBasin2S'),     # "ReplaceWord", "ReplaceWith"
    ('HydroponicsBasinModular', 'HydroponicsBasin1S'),         # and you can copy the entire
    ('', ''),  # line below the next to add more, supports any amount of replacements.
    ('', ''),  # Copy the line without the comment, and place it below the last line before the ]
    ('', ''),
]


Edit all you like, do whatever with it, it's a script that you can learn from and such.  Questions, just ask.  If I happen to not reply to the topic, message me and I'll look and reply publicly (unless you decide to ask privately, public is better for it will help others too).

EDIT: Oh yea, you also have to change the line next to the last line.  I forgot to put that into a variable and put it up top, that's just if you want the final print (message) to display something else.  I'll get around to changing that later.  I want to be lazy for a while.

EDIT2: Ok, I changed it now, so I can be lazy longer without having a pending task.  :|
Click to see my steam. I'm a lazy modder who takes long breaks and everyone seems to hate.