Jump to content

create vessel in-game


Recommended Posts

You would probably have to manually assemble the vessel by building a part hierarchy with the methods available in the Part class, then at some point 'finish it all off' by calling Initialize on the vessel. :-X I believe there already is a plugin for an orbital VAB, you might want to look that up.

Link to comment
Share on other sites

  • 1 month later...

The Orbital Constuction mod works by teleporting a spacecraft you made in the VAB from the launchpad to near the shipyard if the shipyard\'s inventory contains sufficient parts to build it.

Link to comment
Share on other sites

Sometimes i\'ll spend days looking through the codebase, searching on google and making test code to figure things out.

I\'d start with looking into how KSP brings the parts into the game. I know you can access all the assets in the game at runtime, perhaps you can do it that way and convert a game object into a part.

Link to comment
Share on other sites

I\'ve been working on this for the last day or so. I\'m taking a stab at docking.

Just had my first bit of success:


//Target is the target Vessel to clone
ProtoVessel vesselClone = new ProtoVessel(target);

/*
*Note: It appears to create a snapshot of the target\'s orbital parameters,
*and since it takes a non-zero amount of time to load the new vessel, it
*always ends trailing the target if you\'re in orbit.
*/
vesselClone.Load();

screenshot23.png

The target is the vessel to the far right, the center vessel is the one with my test part, and the clones (and their debris) are to the left.

Now to figure out how to modify the parts on the vessel. I imagine the secret lies somewhere ProtoVessel\'s description of the target Vessel.

Link to comment
Share on other sites

And it works? Now, I can make working EVA!

Alchemist gave me code for decoupling and controlling kerbonaut. I worked on it and made kerbonaut destroying for return to ship, but then it become impossible to perform the second EVA. Now, I can make working EVA with Kerbonaut spawn.

How It works? It creates game object and converts it to game vessel with vesselClone.Load(); function? I think the code should have the next view:


Orbit orbitk = new Orbit();
Vessel kerbonaut = new Vessel();
kerbonaut.orbit = orbitk; //Create clone of ProtoVessel orbit;
kerbonaut.orbit = orbitk; //Applies ProtoVessel\'s orbit to Kerbonaut
kerbonaut.Load();

UPD: OH SHIT, kerbonaut.orbit is read only! How to bypass it?

Link to comment
Share on other sites

You\'ll probably need to change the orbit before loading the new vessel, check ProtoVessel.orbitSnapShot

You may want to look at Vessel.orbitDriver as well.

Also, just in case you didn\'t know, EVA\'s look to be the main feature of 0.16 which will probably be out in another 4-6 weeks.

Link to comment
Share on other sites

Well, there\'s no way to \'bypass\' a readonly property per say. Once a field/property has been marked readonly the CLR will enforce that restriction.

You will need to find another class/object to modify to get the same end result.

Link to comment
Share on other sites

Well I figured out how to add parts and move parts relative to the ship in flight.

But I have one huge bug that I can\'t seem to figure out. For whatever reason the current stage of the cloned vessel doesn\'t work -- as in all the parts are in the idle state. If you activate the next stage everything is fine. If you force_activate() the parts in the current stage, they all switch to deactivated for some reason.

Looking at the persistent.sfs file, the cloned ship\'s last stage\'s parts all have a state value of 0 (idle). But the ProtoPart\'s all have the correct state values. I also tried running the vessel\'s ClearStaging() and ResumeStaging() methods, those did not help. I can confirm that manually editing the persistent file so the state = 1 (active) switches those parts back on when switching to the vessel. So now its a matter of figuring out why vessel\'s part\'s serialize with the idle state...

Anyone have any ideas?

Also, anyone know how to programatically switch vessels?

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