Jump to content

KSP + Source Control


NGTOne

Recommended Posts

OK, so first some background:

I'm a software developer when I'm not playing KSP, so I'm very familiar with source control systems (SCS), which provide a way for managing, tracking, and reverting changes in text files (usually code).

I was recently struck by a brainwave - why not apply such a methodology to KSP? After all, savefiles and craft files are nothing but big globs of text. Using an SCS (in my case, git) allows me to both keep a history of changes to my ships (important for my big projects), and mitigate the effects of savefile/craft file corruption (which I encounter on occasion).

It actually works really nicely, too - the question I want to ask everyone else is, is this insane? And has anyone tried something like this before?

Link to comment
Share on other sites

I don't think that's insane at all. It would not be too difficult to scrape your relevant KSP subdirectories and dump them into revision control.

I can see three fairly simple mechanisms one could use to decide when to do a scrape and dump:

1) On a set schedule, eg, every x minutes, or every x minutes if the KSP process is running.

2) On demand (user initiated). Doing this from within the game would require a mod

3) Whenever an eligible file changes on disk ("eligible file" meaning ship files and save files matching whatever filters you like - such as excluding the persistence file).

3 is the one I'd go with.

Link to comment
Share on other sites

No this is not insane at all. I've used git in KSP for a long time now (since 0.18 I think) and it doesn't cause KSP any issues. I initialise my git repos inside each campaign and KSP does not care about the hidden git files being there.

Infact it is so sane that I've written a program that automates the process and does all the git stuff for you, so someone who knows nothing about git can still benifit from it and so you don't have to remember to commit new versions.

The program is called Jebretary and you can download it here..

(thanks @mhoram for mentioning it already)

It runs as a web server on your KSP machine which means you can interface with it from any device on your network (ie tablet, 2nd laptop) and it can manage multiple installs of KSP.

It tracks changes to craft, subassembles and the persistent and quicksave files. With the save files, every single change is tracked and it enables you to load a previous autosave as a quicksave (so you can load it with f9 in KSP). The craft files are tracked at each launch or your can force a new version manually. Tracking the versions at launch means that it automatically saves each version that you deemed was worthy of being launched.

If you delete a craft Jebretary will record it as deleted and allow you to restore it later if you want. You can also write notes about the changes you've made for the craft and save files (helps when looking for a version to go back to, and means you have a development history log for each craft) and Jebretary will tell you information about the parts for each craft and can determine which mods a particular craft uses or if a craft is missing parts.

One of the things that makes git so great for this is perhaps something that git familliars take forgranted, but people who don't know it may not realise; git only tracks the difference between versions. So (for the non-git folk) this means that git only stores the lines of a file that have changed, rather than storing the entire file with each version. A persistent or quicksave file can be 8mb+ in a save with lots of inflight craft, but each time it changes its a relatively small part of the file that changes, as git only stores the individual changed lines it is much more space efficient than simply taking a copy of the file with each version.

Link to comment
Share on other sites

I git my entire ksp dir, including saves, ships and plugins and some configs.

I do it from the git cli, just like with code.

For ships, I iterate, test and commit with updates + message.

For saves, I commit about once per session, with relevant configs (mostly alarm clock and notes). This saves things in case of plugins destroying the save, or in case of me destroying the save.

For plugins, I commit each plugin separately each version. I sometimes trim parts from plugins, and this way I can easily get them back.

I only exclude "unimportant" settings (window positions for plugins, etc), scenarios, and the raw game (KSP_Data, ksp.exe, launcher)... And I might decide to commit those too at some point.

Link to comment
Share on other sites

i .. actually use git to manage my KOs scripts, i thought about it for .craft files, but i was kinda waiting for a parser for crafts that has yet to materialize..

This is something I've indicated interest in developing.

My basic goal with that project would be to form the basis of three modules.

1. A module that tracks the craft versions throughout it's flight and you can bring up a model showing all craft versions inside the build interface. This would be useful for "debugging" fireworks crafts that don't make orbit.

2. An orbital factory module that takes resources(like from Kethane or something else) and builds parts and assembles them into crafts. What you can build depends on the configuration of the factory. That's part of my evil plan to turn KSP into an RTS. :)

3. In-build/In-fight tree selector so you can pass commands(tweaks, etc) to parts of type within a section of the craft tree. This is for extending kOS, mechjeb and a bunch of other mods.

I'm definitely up for a collaboration but, not going to do this solo(yet) on account of doing a majiir challenge repo website. I hope this is not considered thread hijacking...

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...