Jump to content

Loading and spawning Vessel in realtime from craft file...


Recommended Posts

Trying to load a craft file and then load it into the game. I can clone an existing vessel and spawn a new instance of it using something like:


ProtoVessel pv = new ProtoVessel(FlightGlobals.ActiveVessel);
pv.Load(HighLogic.CurrentGame.flightState);

However, if I try to load the craft file using something like:


Vessel tempv = new Vessel();
tempv.parts = ShipAssembly.loadShip("T:\\Programs\\SteamLibrary\\SteamApps\\common\\Kerbal Space Program\\Ships\\VAB\\Two-Stage Lander.craft");
tempv.orbit.Set(FlightGlobals.ActiveVessel.orbit);
tempv.orbit.epoch = tempv.orbit.epoch - .01;
ProtoVessel pv = new ProtoVessel(tempv);
pv.Load(HighLogic.CurrentGame.flightState);

I'm getting a reference object not set to an instance of blah blah runtime error. Did a little bit of troubleshooting last night to figure it out but I figured I'd come on here and see if anyone has done this before. Are there any mods out there that do something like this so I can reference the source?

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