Jump to content

How does the game build a craft using a .craft file?


Recommended Posts

So this might be a very weird question but I took a look at a .craft file and looked at individual parts. From what I could find there isn't a specific ID/value/name that tieds a specific part in a .craft file to a part in the Parts folder. The reason I need this is because I want to write a script which will take a craft file and output list of all the parts and mabey save all part meshes required to a specific folder. However I don't know how by reading a craft file I can identify specifioc parts in the Parts folder.

Any suggestions?

Thanks.

Link to comment
Share on other sites

if I am understanding you correctly @EugeneLevinson - what you are looking for is the reference KSP uses to refer to parts.

If you look at any part.cfg file (txt) - one of the first items you will see is name = xxxx

xxx is what you are looking for.

Good part naming does not include spaces or non-standard characters like _ (underscore) but does include a-z;A-Z;0-9;-

bad naming (still allowed) can include spaces, underscores, and periods.

Spoiler

PART
{
    name = noseCone
    module = Part
    author = AlexanderM
    mesh = aerodynamicNoseCone.mu
    scale = 1.0
    rescaleFactor = 1
    node_stack_bottom01 = 0.0, 0.0, 0.0, 0.0, -1.0, 0.0
    CenterOfDisplacement = 0.0, 0.2, 0.0
    TechRequired = stability
    entryCost = 2000
    cost = 240
    category = Aero
    subcategory = 0
    title = #autoLOC_500109 //#autoLOC_500109 = Aerodynamic Nose Cone
    manufacturer = #autoLOC_501623 //#autoLOC_501623 = Goliath National Products
    description = #autoLOC_500110 //#autoLOC_500110 = Aerodynamic, lightweight and mostly non-explosive. As a reminder to all personnel operating nearby, this part is really sharp and it'd probably hurt if you fell on it.
    attachRules = 1,0,1,1,0
    stackSymmetry = 2

hope this helps.

Link to comment
Share on other sites

11 hours ago, zer0Kerbal said:

if I am understanding you correctly @EugeneLevinson - what you are looking for is the reference KSP uses to refer to parts.

If you look at any part.cfg file (txt) - one of the first items you will see is name = xxxx

xxx is what you are looking for.

Good part naming does not include spaces or non-standard characters like _ (underscore) but does include a-z;A-Z;0-9;-

bad naming (still allowed) can include spaces, underscores, and periods.

  Hide contents

PART
{
    name = noseCone
    module = Part
    author = AlexanderM
    mesh = aerodynamicNoseCone.mu
    scale = 1.0
    rescaleFactor = 1
    node_stack_bottom01 = 0.0, 0.0, 0.0, 0.0, -1.0, 0.0
    CenterOfDisplacement = 0.0, 0.2, 0.0
    TechRequired = stability
    entryCost = 2000
    cost = 240
    category = Aero
    subcategory = 0
    title = #autoLOC_500109 //#autoLOC_500109 = Aerodynamic Nose Cone
    manufacturer = #autoLOC_501623 //#autoLOC_501623 = Goliath National Products
    description = #autoLOC_500110 //#autoLOC_500110 = Aerodynamic, lightweight and mostly non-explosive. As a reminder to all personnel operating nearby, this part is really sharp and it'd probably hurt if you fell on it.
    attachRules = 1,0,1,1,0
    stackSymmetry = 2

hope this helps.

Well, thats the issue. In the config they have a specific name, but in the craft file a part name doesn't nessesarely match the name that part has in the config. Some are the same but some aren't. For example it's called "mk1-3pod" in both part config and craft file. But in craft file it is called "parachuteLarge_4294312400" which in the part config is called "parachuteRadial" and the file name is  "parachuteMk2-R.cfg". So I still not sure how can I by readig=ng the craft file identify each specific part. Or is there a table/data base which has the names in the craft file matched with the location/name of the part files?

 

Link to comment
Share on other sites

1 hour ago, EugeneLevinson said:

Well, thats the issue. In the config they have a specific name, but in the craft file a part name doesn't nessesarely match the name that part has in the config. Some are the same but some aren't. For example it's called "mk1-3pod" in both part config and craft file. But in craft file it is called "parachuteLarge_4294312400" which in the part config is called "parachuteRadial" and the file name is  "parachuteMk2-R.cfg". So I still not sure how can I by readig=ng the craft file identify each specific part. Or is there a table/data base which has the names in the craft file matched with the location/name of the part files?

 

You are getting your parachutes mixed up. The Mk2-R is indeed called ParachuteRadial in the Craft file (I just tested). The numbers are the part/vessels "persistentID" - in short you want the bit before _<random string of numbers>

Off the top of my head, I think "parachuteLarge" is the 16-XL

Edited by severedsolo
Link to comment
Share on other sites

6 hours ago, severedsolo said:

You are getting your parachutes mixed up. The Mk2-R is indeed called ParachuteRadial in the Craft file (I just tested). The numbers are the part/vessels "persistentID" - in short you want the bit before _<random string of numbers>

Off the top of my head, I think "parachuteLarge" is the 16-XL

Could you provide an exaple? Like the string in the craft file which matches with a part file. I just can't connect the two for some reason.

Link to comment
Share on other sites

13 hours ago, EugeneLevinson said:

Could you provide an exaple? Like the string in the craft file which matches with a part file. I just can't connect the two for some reason.

https://1drv.ms/u/s!AtG2PODa0fmwisRhyfABe0jsn1uVNw?e=vG6GYg

Really simple craft file, just with a Mk1-3 pod and a radial parachute.

Line 17 (in the first PART ConfigNode) - part = mk1-3pod_4294626518 - breaking that down, that's the "name" in the parts .cfg file (mk1-3pod) and an ID string.
The next PART ConfigNode (Line 363) I see: part = parachuteRadial_4294621910 - again, it's the part name as defined in the cfg, plus _<string of numbers>

It seems I was wrong about it being the parts persistentID though - that number doesn't match the persistentID (which is also stored in the Craft file) - I don't know what that number is, but still, you can use Regex or similar to get rid of the numbers.

Link to comment
Share on other sites

9 hours ago, severedsolo said:

https://1drv.ms/u/s!AtG2PODa0fmwisRhyfABe0jsn1uVNw?e=vG6GYg

Really simple craft file, just with a Mk1-3 pod and a radial parachute.

Line 17 (in the first PART ConfigNode) - part = mk1-3pod_4294626518 - breaking that down, that's the "name" in the parts .cfg file (mk1-3pod) and an ID string.
The next PART ConfigNode (Line 363) I see: part = parachuteRadial_4294621910 - again, it's the part name as defined in the cfg, plus _<string of numbers>

It seems I was wrong about it being the parts persistentID though - that number doesn't match the persistentID (which is also stored in the Craft file) - I don't know what that number is, but still, you can use Regex or similar to get rid of the numbers.

Hmm, Mk1-3 does match up with a config file and a mesh file but there is no file called "parachuteRadial" and I can't find it in the config file of the parachute, though mabey I understood your explanation wrong.

Gonna keep searching for now, do you know if there is an official documentation on how ksp files are structured like for the people who make mods?

Link to comment
Share on other sites

 

11 hours ago, EugeneLevinson said:

there is no file called "parachuteRadial" and I can't find it in the config file of the parachute, though mabey I understood your explanation wrong.

Ah, I see your confusion. The file names do not always match up to the part names.

But, if you go to: <YourKSPDirectory>/GameData/Squad/Parts/Utility/parachuteMk2-R/parachuteMk2-R.cfg

Open it up, and the first value in the ConfigNode is: name = parachuteRadial

This name in the cfg is what KSP uses.

 

 

11 hours ago, EugeneLevinson said:

if there is an official documentation on how ksp files are structured like for the people who make mods?

Official? No. But here's a wiki page that gives a broad overview of ConfigNodes:

https://wiki.kerbalspaceprogram.com/wiki/User:Greys/The_CFG_File_and_ConfigNodes

Link to comment
Share on other sites

15 hours ago, severedsolo said:

 

Ah, I see your confusion. The file names do not always match up to the part names.

But, if you go to: <YourKSPDirectory>/GameData/Squad/Parts/Utility/parachuteMk2-R/parachuteMk2-R.cfg

Open it up, and the first value in the ConfigNode is: name = parachuteRadial

This name in the cfg is what KSP uses.

 

 

Official? No. But here's a wiki page that gives a broad overview of ConfigNodes:

https://wiki.kerbalspaceprogram.com/wiki/User:Greys/The_CFG_File_and_ConfigNodes

Thanks

 

Link to comment
Share on other sites

I already built a tool that does this...   if interested, PM me.

In my case, I also wanted to map which nodes on the tech tree are required for a given craft design.

Low-tech_starter_plane.jpg

So it reads a craft file and builds a part database... then it cross-refs the craft parts against the tech tree to produce this report.

Since I build a lot of stuff in sandbox, it helps me figure out for any craft what nodes I should unlock next if I want to use the craft in career mode.  Additionally, it tells me if I have one outlier part (ladders are notorious) that I could drop from a design to use the craft earlier in career.  It also tracks which nodes I have unlocked in a career and calculates the science cost required to unlock the remaining nodes I need for a given craft.  ...and it tells me what the facility upgrade requirements are based on the part count, dimensions, weight, etc.

At this point, I have not actually shared it with anyone.  It's based in MS Excel, the script is the underlying VBA language.

Edited by XLjedi
Link to comment
Share on other sites

On ‎1‎/‎12‎/‎2020 at 7:40 AM, EugeneLevinson said:

Well, thats the issue. In the config they have a specific name, but in the craft file a part name doesn't nessesarely match the name that part has in the config. Some are the same but some aren't. For example it's called "mk1-3pod" in both part config and craft file. But in craft file it is called "parachuteLarge_4294312400" which in the part config is called "parachuteRadial" and the file name is  "parachuteMk2-R.cfg". So I still not sure how can I by readig=ng the craft file identify each specific part. Or is there a table/data base which has the names in the craft file matched with the location/name of the part files?

 

@EugeneLevinson 

This is exactly how I managed it:  "Or is there a table/data base which has the names in the craft file matched with the location/name of the part files?"

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