Using different runs save data between save files


Recommended Posts

I've bought the game on GOG so I don't have Steam Cloud. Last night, since there was no way I could use my save data, I decided to start the game from scratch. Thing is, the run went really smooth and wanted to keep playing it in my original save. I've checked the .lua save file but I'm not sure what I should cut and what I shouldn't. If anyone knows anything, I'll be forever thankful :)

 

Spy on!

Link to comment
Share on other sites

I'm not a Lua expert nor familiar with Klei's game engine, but I've seen enough data languages to make some informed guesses about how to do what you want. However, I have never tried to insert new objects into my save file so I have no idea if my advice will actually work. If you try it, make backups of all the files both before and after editing. Also be sure to use an editor that understands Unix line endings (e.g. Notepad++ rather than Notepad).

 

The first part of the save file is a set of Lua tables, each of which is given a unique numeric ID. The tables are delimited by blank lines, and start with a line like "table = objects [ 0x00000001 ]". Following that, are lines like "table [ key ] = value" where the key is either a number or a quoted string. If the value is of the form "objects [ hexnumber ]" then it is a reference to another table which is defined elsewhere in the file, probably below this table.

 

Summary:

1) find your save game in the source file

2) extract all the objects that make up the save into a temporary file

3) renumber them

4) insert them into the target file

5) add a new savegame pointer and initializers to the target

 

Step 1:

In your source file, object 1 will have a line like "table [ "saveSlots" ] = objects [ 0x00000002 ]". Find object #2 or whatever object number this line references. That object is your list of saved games. In that object, there will be an entry like "table [ 1 ] = objects [  0x00000003 ]" (again, your ID numbers may vary).

 

Step 2:

Copy object #3 (or whatever result you got from step 1) into your temporary file. Look for all references of the form "objects [ <somenum> ]", find those objects, and copy them. Look for all the object references in those newly copied objects, find even more objects, and copy them. Rinse and repeat until you're sure that your temp file contains every object referenced by some other object in your temp file. These objects define your agency, your agents, their augments and items, your available missions, your current mission, etc. In my game, these objects happen to be contiguous, but Im not sure that is guaranteed.

 

Step 3:

Look at the target save file. Find the highest object number in use  (e.g. "0x000000F4"). Now assign every object in your temporary file a new sequential ID starting with the next number (in my example, that would be "0x000000F5"). Any time you renumber an object, you need to change all the references to that object as well. If you change "objects [ 0x0000003A ]" into "objects [ 0x000000123 ]", you need to do it to every place that "objects [ 0x0000003A ]" is mentioned.

 

Step 4:

Inset the contents of your temp file into the target between the last existing object and the line that just says "end" (the end of the init function).

 

Step 5:

Find the list of saves in the target (probably table #2). Add a new entry to the array pointing to the root of the object tree you just copied (e.g. "table [ 2 ] = objects [ 0x000000F5 ]" ).

 

Now go to the bottom of the save file and look for a list of likes like "[ 0x0000000017 ] = {}". Add new entries in the same style for all of your new objects.

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.