Jump to content

Craft files auto-converter?


Recommended Posts

Seeing that the old parts will be depreciated, will we get a part converter that may at least concert them all automatically, even if it will look ugly?

EDIT: 

I decide that, instead of waiting for someone to write one that will forcibly convert the old craft files into new, I decide to try to write one. That being said, since it's rusty, it's like 1.6 will be out by the time I got it out. (sidenote: Should I go Java, Xamarin, or just good old Bat/PS script?)

However, the following can be used by find and replace on text editors (I recommend notepad++):

Note: Note sure. but **Make sure you search by WHOLE WORD ONLY!**

Note 2: ** They will use the new Black on white color. I will look for orange color for the Jumbo-64**

Note 3: changed the order so the longer string name will be converted before the smaller ones does

// TR-2V Stack Decoupler → TD-06 Decoupler  
stackDecouplerMini to Decoupler.0

// TR-18A Stack Decoupler → TD-12 Decoupler  
stackDecoupler to Decoupler.1

// Rockomax brand decoupler → TD-25 Decoupler  
decoupler1-2 to Decoupler.2

// TR-38-D → TD-37 Decoupler  
size3Decoupler to Decoupler.3

// TR-2C Stack Separator → TS-06 Stack Separator  
stackSeparatorMini to Separator.0

// TR-XL Stack Separator → TS-25 Stack Separator  
stackSeparatorBig to Separator.2

// TR-18D Stack Separator → TS-12 Stack Separator  
stackSeparator to Separator.1

// ROUND-8 Toroidal Fuel Tank → R-12 'Doughnut' External Tank  
toroidalFuelTank to externalTankToroid

// Rockomax X200-8 Fuel Tank → same name  
fuelTank4-2 to Rockomax8BW

// Rockomax X200-16 Fuel Tank → same name  
fuelTank2-2 to Rockomax16.BW

// Rockomax X200-32 Fuel Tank → same name  
fuelTank1-2 to Rockomax32.BW

// Rockomax Jumbo-64 Fuel Tank → same name  
fuelTank3-2 to Rockomax64.BW
//orange color unfortunately cannot be made by a simple "part swap" in the name, as it's a variable for "variant".

// Mk 1-2 Pod → Mk 1-3 Pod  
Mk1-2Pod to Mk1-3Pod

 

 

Edited by Jestersage
Link to comment
Share on other sites

3 minutes ago, Jestersage said:

But what about those that we ourselves design but have not upload?

u can change it manually, the parts are still in game but hidden somewhere (u had to look inside "Manufacturer" tab)

Link to comment
Share on other sites

3 hours ago, [INDO]dimas_1502 said:

maybe u can ask @katateochi how the kerbalx part changer works,

tbh it's pretty simple; parse the file for all part names (full name, including the identifier values) and select from that those which have a legacy part name.
Then split the part name string on "_" and take the first part (that's just the name without the id), string replace that with the new name. So something like "Mark1-2Pod_4294774928" becomes "mk1-3pod_4294774928", then grep the whole craft file for any instances of "Mark1-2Pod_4294774928" and replace with "mk1-3pod_4294774928".

What that doesn't do is add in the extra modules which define which style they use, but if you load the craft in KSP 1.4.0 and save it, KSP will add those extra modules in. 

Here's the Ruby code that I'm using on KX (the unclear bit is the line; self.file.find_all("part"), that's from the KX craft file parser, and that just selects all lines in the file that start with "part =")

module Upgradeable

  UpgradeChanges = {      
    "Mark1-2Pod" => "mk1-3pod",
    "fuelTank4-2" => "Rockomax8BW",
    "fuelTank2-2" => "Rockomax16.BW",
    "fuelTank1-2" => "Rockomax32.BW",      
    "fuelTank3-2" => "Rockomax64.BW"      
  }

  def upgrade_13x_parts_to_140 args = {:preview => true}
    raw = self.craft_file  

    UpgradeChanges.each do |old, new| 
      old_parts = self.file.find_all("part").select{|p| p.match(/^#{old}/)}      
      old_parts.each do |part|
        new_name = part.sub(part.split("_")[0], new)
        raw.gsub!(part, new_name)
      end
    end

    return raw if args[:preview]
    self.craft_file = raw
  end

end

Note, this doesn't change the decouplers or the fairings (but you could just add them into UpgradeChanges).
I decided that changing the decouplers would be a problem because they have different sizes so you'll get weird offset issues.  If you come up with something that can deal with those nicely I'd be interested.
And the fairings just seems to upgrade on their own without needing any work (at least as far as I've seen).

 

10 hours ago, Jestersage said:

But what about those that we ourselves design but have not upload?

well, I don't want people abusing this, because it puts load on KerbalX, but you can upload a craft (without publishing it), download the upgraded version and then delete the craft. Just please don't hammer the site doing that, uploading is the most intensive process and lots of people doing that will slow things down for other users. KX is about sharing with the community, so doing that is just taking up a resource without contributing, so yeah, don't abuse it, Thanks! 

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