Jump to content

.21 and No more end flight problems


Recommended Posts

Pretty new to programing but I know that this line of code no longer is valid.

FlightDriver.TerminateCurrentFlight ();

I have tried many different things to replace this with.. But nothing seems to work (always reverts the flight back to preflight)

And I can't seem to find how to call up the Recover Vessel Option that you get from the Tracking Screen, inside the game screen.

Of course we want to recover the vessel without killing the crew.. too.

Any ideas from the more experience programers.

Link to comment
Share on other sites

I think those reset the flight.. Be the same thing as doing The Revert to launch and Revert to pre Launch (IE in hanger). Which would reset the time.

This little code was part of the mission controller mod. It was used with recycle vessel option in the old version. When a vessel landed or splashed down you could recycle it within Mission Controller.. And after it was recycled the program ran like this.

if (status.recyclable) {
VesselResources res = vesselResources;
showCostValue("Recyclable value: ", res.recyclable(activeVessel.Landed), styleCaption);
if (GUILayout.Button ("Recycle and end flight!")) {
manager.recycleVessel (activeVessel, res.recyclable(activeVessel.Landed));
FlightDriver.TerminateCurrentFlight ();
FlightResultsDialog.showExitControls = true;
FlightResultsDialog.Display ("Vessel has been recycled!");
recycled = true;

I changed it to this because the FlightDriver.TerminateCurrentFlight (); is no longer part of the code (its what crashed the Mission Controller in .21)

 if (status.recyclable) {
VesselResources res = vesselResources;
showCostValue("Recyclable value: ", res.recyclable(activeVessel.Landed), styleCaption);
if (GUILayout.Button ("Recycle and end flight!")) {
manager.recycleVessel (activeVessel, res.recyclable(activeVessel.Landed));
FlightResultsDialog.allowClosingDialog = true;
FlightResultsDialog.Display ("Vessel has been recycled!");
recycled = true;

Totally took out the TerminateCurrentFlight and Replaced ShowExitControls with allowClosingDialog.. The Show ExitControls also resets the flight and Time.. Which is not what we want to do.

When you go into the trackingStation there is a new option that allows you to Recover a Vessel when it is splahsed or landed.. I have no idea how to set it up.

the only thing I could find about Recover Vessel was this.

ShipConstruction.RecoverVesselFromFlight(ProtoVessel, FlightState)

And I can't get it to work because I have no idea how to setup (ProtoVessel, FlightState)

So basically I would like it to be like the original code.. I would like to EndTheFlight right there and then.. Instead of exiting out of the screeen and going to the Tracking Station to do it.. Of course without Ressetting the Time, and getting the kerbals back without killing them. So when you take off on say day 1... And come back on day 5.. If you revert it sets it back to day 1.. Like flight never happened.. We want it to stay at day 5.. And the flight did happen.

Edited by malkuth
Link to comment
Share on other sites

To emulate the function of TerminateCurrentFlight(), you could do this:

public static void TerminateCurrentFlight()
{
foreach (ProtoCrewMember crewMember in FlightGlobals.ActiveVessel.GetVesselCrew())
{
crewMember.rosterStatus = ProtoCrewMember.RosterStatus.AVAILABLE;
}
FlightState state = new FlightState();
if (state.activeVesselIdx != -1)
{
state.protoVessels.RemoveAt(state.activeVesselIdx);
}
GamePersistence.SaveFlightState(state, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
}

Link to comment
Share on other sites

Thanks Frement I try this out.. Don't know if I want to implement this though because I don't really want to change Nobody code too much right now. But for my own personal use I might give it a go.

Does seem though that the SaveFlightState is also old code.. Sets a warning about using a newer call. I replaced that part with this.

GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);

Link to comment
Share on other sites

Thanks Frement I try this out.. Don't know if I want to implement this though because I don't really want to change Nobody code too much right now. But for my own personal use I might give it a go.

Does seem though that the SaveFlightState is also old code.. Sets a warning about using a newer call. I replaced that part with this.

GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);

Sure, so does that code do what you wanted? :)

Link to comment
Share on other sites

Yes it does.. It saves the flight and everything And I changed the Menu Back to the way it was originally.. But the user still has to go into tracking station to actually get rid of the craft that has landed.. IE recover.

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