Jump to content

Saving mod data to sfs files


MarkusA380

Recommended Posts

Hello there!

I've been working on my mod, PersistentRotation, for quite a long time. If you never heard of it make sure to check it out, to know what I am talking about.

The mod is currently saving it's data into a custom made cfg file. Every time the game quicksaves or switches scenes, a new file is generated.

While I have added code to clean up deprecated versions of the file, I still have the feeling that it isn't the optimal solution to store the data.

A while ago, I have heard about saving mod data to the game's sfs files. This would of course be a a lot more effective way of storing data.

Now, the problem is, my mod saves data per vessel and has no custom parts at all.

Could someone explain me how to do this or send me the corrseponding piece of code?

Thanks in advance.

Link to comment
Share on other sites

You could just move the data into a Scenario (which KSP will save into the persistent.sfs file) instead of manually saving it into a separate file. Many mods save their data in a Scenario like this (AltFunding which I made does this, USI Life Support by RoverDude does, SCANSat does, etc).

The things to look for are subclasses of ScenarioModule and calls to Game.AddProtoScenarioModule().

I've never used VesselModules, but converting to use that would probably be a bigger change (but I also suspect it would be a better approach in the long-term since your data really is specifically tied to each vessel and not just generic per-save information).

Edit: I had assumed VesselModule can persist data the same way PartModule does, but the post Boris linked above says that VesselModule itself provides no facilities for persistence. If so, then ScenarioModule is what you'll want.

Edited by nathan1
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...