Fractal Softworks Forum

Starsector => Mods => Modding Resources => Topic started by: Wyvern on January 21, 2013, 04:25:27 PM

Title: Saved Variant Extractor
Post by: Wyvern on January 21, 2013, 04:25:27 PM
Built myself a simple little java program to extract ship variants from a saved game and convert them into .variant files suitable for inclusion in a mod.

Why is this useful?  It means you can use the in-game editor - which is quite helpful if you want to, say, design a variant that could be legally designed by someone with some specific set of skills.  (How many ordnance points does an onslaught have when you have level four technology aptitude?  I don't know, and have no interest in doing the calculations myself.)

Anyway.  To use, compile the provided code, then run it; it takes a single command line argument, which is the path to the campaign.xml file for the saved game you want to extract variants from.  It generates a set of .variant files stored in the saved game folder; you can then move those wherever.

Yeah, I could clean it up some - provide command line help, maybe package it into a jar with a basic UI so you don't need to worry about compiling it yourself - but, eh.  Made this for my own use; I may do some of that work later if there's enough outside interest.

[attachment deleted by admin]
Title: Re: Saved Variant Extractor
Post by: silentstormpt on January 21, 2013, 06:15:02 PM
Thanks for your work, i never thought of using the saved game to grab saved refit variants
Title: Re: Saved Variant Extractor
Post by: Sproginator on May 31, 2013, 11:20:49 AM
Hey guys, Sorry for the necro, But I REALLY need this for my station ships, Any chance you could teach me how to compile it? or improve it to an EXE file?
Title: Re: Saved Variant Extractor
Post by: Wyvern on May 31, 2013, 12:37:08 PM
So, if you've got java installed, you should be able to run "javac SavedVariantConverter.java", and then run the app by "java SavedVariantConverter /path/to/save/campaign.xml".  I can package it into a runnable jar for you, but not immediately; I've got some family emergency type issues to attend to for the next week and a half.  If you really can't get it working yourself, and need it sooner than I can get to it, then you can ask around for someone else to help - for example, I'm sure LazyWizard would be able to help, and there are probably others.

Apologies, but I just can't guarantee the time to offer any further help just now.
Title: Re: Saved Variant Extractor
Post by: Sproginator on May 31, 2013, 12:40:01 PM
I'd really appreciate it if you could package it, But no rush :)
Title: Re: Saved Variant Extractor
Post by: LazyWizard on June 02, 2013, 09:34:58 PM
I took the liberty of making a very rough jar (http://www.mediafire.com/download/6clkh5hnmvma8oi/Saved_Variant_Converter.zip) for those who don't want to compile this for themselves. The only changes I made to the script itself was to add a file selector so you don't need to use the command line (command line options should still work, though), and have the program open the save directory after the variants have been extracted to save time.

If you run into any bugs, it's completely my fault. I threw this together in a few minutes. :)
Title: Re: Saved Variant Extractor
Post by: Sproginator on June 03, 2013, 12:12:32 AM
There he goes again!

Bloody hell lazy!

Will you stop!

Being so damn AWESOME ;P
Title: Re: Saved Variant Extractor
Post by: Sproginator on June 04, 2013, 01:07:33 PM
I took the liberty of making a very rough jar (http://www.mediafire.com/download/6clkh5hnmvma8oi/Saved_Variant_Converter.zip) for those who don't want to compile this for themselves. The only changes I made to the script itself was to add a file selector so you don't need to use the command line (command line options should still work, though), and have the program open the save directory after the variants have been extracted to save time.

If you run into any bugs, it's completely my fault. I threw this together in a few minutes. :)

It doesnt work :P
Title: Re: Saved Variant Extractor
Post by: LazyWizard on June 04, 2013, 01:48:50 PM
Any details on how it doesn't work?

How are you running it? If you add the word pause to a new line in the bat file (assuming you run Windows), what text is on the screen when the program is done?
Title: Re: Saved Variant Extractor
Post by: LazyWizard on June 04, 2013, 02:19:52 PM
Ah, I see, the script doesn't check for write permissions. I didn't run into it because I install my games into my user directory.

Here's a quick, very ugly patch. (http://www.mediafire.com/download/ciusb55ka3sas57/Saved_Variant_Converter.zip)
Title: Re: Saved Variant Extractor
Post by: Sproginator on June 04, 2013, 03:57:34 PM
Cheers, will take a look tomorrow :)
Title: Re: Saved Variant Extractor
Post by: Sproginator on June 05, 2013, 09:47:30 AM
Works perfectly! Please sticky this someone :D
Title: Re: Saved Variant Extractor
Post by: pablo on August 21, 2013, 11:08:06 AM
It dosen't work for me. What Java version you use ?
Title: Re: Saved Variant Extractor
Post by: DrakonST on November 14, 2016, 09:22:42 AM
It doesn't work any more? When I use this program she takes empty variants. Without weapon and hullmods.

Code
{
  "displayName": "Advanced II",
  "fluxCapacitors": 0,
  "fluxVents": 47,
  "hullId": "valk_almire_II",
  "hullMods": [
  ],
  "variantId": "valk_almire_II_Advanced II",
  "weaponGroups": [
    {
      "autofire": false,
      "mode": "ALTERNATING",
      "weapons": {
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
      }
    },
    {
      "autofire": true,
      "mode": "LINKED",
      "weapons": {
      }
    },
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
      }
    },
    {
      "autofire": false,
      "mode": "LINKED",
      "weapons": {
      }
    },
  ]
}
Title: Re: Saved Variant Extractor
Post by: Wyvern on November 14, 2016, 11:07:20 AM
Hm.  Probably the code is a bit out of date with recent updates to Starsector.  ...Unfortunately, I seem to have misplaced the original source code, which makes it a bit hard to update.

I can try to get a working version of this put together again this weekend, though; it was pretty simple to make the first time, so it shouldn't be that much harder to rebuild from scratch.  (Or, if the version you've got includes source code, I can PM you my email address, have you send me the existing version, and then work from that.)
Title: Re: Saved Variant Extractor
Post by: DrakonST on November 14, 2016, 11:18:49 AM
Hm.  Probably the code is a bit out of date with recent updates to Starsector.  ...Unfortunately, I seem to have misplaced the original source code, which makes it a bit hard to update.

I can try to get a working version of this put together again this weekend, though; it was pretty simple to make the first time, so it shouldn't be that much harder to rebuild from scratch.  (Or, if the version you've got includes source code, I can PM you my email address, have you send me the existing version, and then work from that.)
You can't load him from here?
http://www.mediafire.com/download/ciusb55ka3sas57/Saved_Variant_Converter.zip (http://www.mediafire.com/download/ciusb55ka3sas57/Saved_Variant_Converter.zip)
Title: Re: Saved Variant Extractor
Post by: Wyvern on November 20, 2016, 07:13:55 AM
Oh, apparently I can.  Huh, I remember that download not working the last time I tried it.  Okay then...
Title: Re: Saved Variant Extractor
Post by: Wyvern on November 20, 2016, 07:37:39 AM
If you're curious, the change was a perfectly sensible one: Alex changed all the <string>blah</string> entries in the save format to <st>blah</st>.  I bet that actually saved a decent chunk of file size - but it broke my code that was looking for things named <string>.

Attaching the fixed code; yeah, the forum will auto-wipe that after a while, but maybe LazyWizard will be kind to those that aren't developers and package it up again; until then, my original instructions for compiling & running it should work fine.  (Note to self: maybe next weekend, I should sit down and do a proper packaging up myself; there are a few usability improvements that'd be worth considering...)

[attachment deleted by admin]