Jump to content

Anyone ever tried to "program" a craft?


Draconiator

Recommended Posts

I.E., don't build it in-game, but use extensive knowledge of the parts and where they all fit to actually WRITE a .craft file by hand.  I came up with this question when I downloaded a craft from here that threw a parts error, because the landing gear it used was one I didn't have.  So I just memorized the name of it, opened the .craft file via Notepad, and deleted every instance of that part.  Loaded up KSC again, and the craft loaded up fine.  I had to put some gear on, but it works perfectly now.

Link to comment
Share on other sites

Building a craft by hand (edit: I mean by text editor) seems like an exercise in masochism what with the wonderful VAB available :) 

In college we had a project to build a 2D truss structure, every node had to be entered as well as every connection between the nodes. Never again will I do that!

Edited by Waxing_Kibbous
Link to comment
Share on other sites

It would be cool to write a simple program to generate .craft files.  For example, I have some spreadsheets that help me choose the best stages for my crafts (fuel tanks + engines) by calculating the delta V of all possibilities and sorting them by cost, then I visually scan for an entry that has enough delta V.  Next step would be to write a simple Python program to do that.  Outputting the .craft file would be the next logical step...

Link to comment
Share on other sites

2 minutes ago, Fiddlestyx said:

I've written codes for robots before, about 12,000 lines. It isn't too hard once you know the language. To write a .craft file you would basically need to learn the "language".

Er... actually it's a good deal more complex than that.

Even if you are familiar with the structure of the craft files, you still need to know the correct placement of all the components (position and rotation), not just individually but also in relation to those which they are connected to, taking into account the passing of transforms through the hierarchy.

I've actually done something similar, albeit much simpler when I had to put together a set of 3D data for a widget graphic (a stock ticker with prices on blocks that rolled around when it updated). Where I was working we didn't have an art toolchain at the time, so I had to pull all the data necessary from a 3D package (vertex array, references to those vertices to form the triangles and the UV's) and change it to match the requirements of the renderer we used. It was only 56 triangles but it was a complete pain to do.

It's not quite the same thing as what you've suggesting, but has similar issues, i.e. knowing the data structure is only part of the task.

The data for very early 3D graphics were constructed "by hand", but that process would be horribly painful to use when even the most basic editing tool is available.

 

Link to comment
Share on other sites

I use OpenSCAD for very simple 3d structures for printing. It has a language specifically built for making 3d construction easy, and it is still extremely slow to use. Writing a .craft by hand would be next to impossible for all but the very simplest vessels, and painful even for those.

Link to comment
Share on other sites

You could (more accurately I could) definitely  write a .craft READER. An out-of-game app that turns the file into a collapsible tree-view. There are more complex CGI apps that store files similarly and THEY have out-of-app readers.

Once in there you could do *some* things. Finding and removing broken struts is what I had in mind.

You MIGHT be able to write a simple one.

Link to comment
Share on other sites

14 hours ago, Fiddlestyx said:

I've written codes for robots before, about 12,000 lines. It isn't too hard once you know the language. To write a .craft file you would basically need to learn the "language".

Data structures and programming languages aren't the same thing. There is a very poor semantic in data structure. On the opposite programming languages have a very strong semantic. You can understand many thing even you don't know much about an algorithm or the language itself.

So it's usually more difficult to create data structure from scratch than create a program to do so.

I'm no even sure that Squad devs would be able to do that.

 

Link to comment
Share on other sites

When deleting parts from craft files you should also remove all other references to the part from the other parts.  Specifically, the parent part will have a "link = <part value from surface attached part>" entry for each of its children.  These may get safely ignored by the stock game code when loading the vessel though I wouldn't put money on it without running some in-depth tests and carefully examining the in-memory version of the vessels after loading.

Deleting parts in .sfs files is much harder as all the links between parts are stored as the index in the part array rather than an id of the part.  So, when you delete a part you have to run through the whole of the vessel modifying all the attachment indices for parts that are after the deleted part in the array.  This is usually too much work and too easy to break it so parts are usually replaced with a stock part instead of deleting them (e.g when removing old KER parts from a save it is much easier to replace them with thermometers or some other simple part).

Link to comment
Share on other sites

2 hours ago, Brainlord Mesomorph said:

You could (more accurately I could) definitely  write a .craft READER. An out-of-game app that turns the file into a collapsible tree-view. There are more complex CGI apps that store files similarly and THEY have out-of-app readers.

Once in there you could do *some* things. Finding and removing broken struts is what I had in mind.

You MIGHT be able to write a simple one.

One could probably do quite a bit with a .craft reader, and I agree that it'd be relatively easy to do. I'm having a bit of trouble thinking of anything that one would want to do that'd be easier out of game than in game though.

I just looked through a simple .craft file, and...no. Please no. Position/rotation would be tedious but straightforward. The module information though would be annoying if one can't just copy/paste from an existing .craft file.

Edit

I  think I've actually written a .craft reader back in 0.16 or so. It didn't do much, but it wasn't too hard to get a list of parts out.

Edited by kujuman
Link to comment
Share on other sites

55 minutes ago, kujuman said:

One could probably do quite a bit with a .craft reader, and I agree that it'd be relatively easy to do. I'm having a bit of trouble thinking of anything that one would want to do that'd be easier out of game than in game though.

 

Find and fix (or remove) broken struts and fuel lines.

find and Replace parts while keeping what's attached.

re-rooting

displaying (and fixing) fuel flow .

look for file corruption!  (I think we build the Kraken into our own ships)

Link to comment
Share on other sites

1 hour ago, kujuman said:

One could probably do quite a bit with a .craft reader, and I agree that it'd be relatively easy to do. I'm having a bit of trouble thinking of anything that one would want to do that'd be easier out of game than in game though.

Make it an Android/iOS App so one can view/check craft on the mobile. :cool:

Link to comment
Share on other sites

This would be really silly, because when you are finished and want to check your results, you have to start up the game anyway (and it's a lot faster building it there in the first place).

I edited a lot of .part or .craft files in my 1000+ hours of KSP time (mainly welded things), its not really hard, outside of calculating the values for the nodes and position for the models maybe. Just VERY tedious.

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