Jump to content

Switching Vessels on button press.


Recommended Posts

Hey all,

I've searched a little and can't find what I'm looking for. I've got a list of vessels from FlightGlobals, how would I switch to it like you would in the tracking station?

This is what I have so far (this is also a partless plugin, running as an addon):


for (int cVessel = 0; cVessel < FlightGlobals.Vessels.Count; cVessel++)
{
Vessel sVessel = (Vessel)FlightGlobals.Vessels[cVessel];

if (sVessel.state != Vessel.State.ACTIVE)
{
if (GUILayout.Button(string.Format("{0} [{1}]", sVessel.vesselName, sVessel.situation), buttonStyle))
{
//sVessel.GoOnRails(); ?
}
}
}

Thanks for reading.

Link to comment
Share on other sites

Hello,

I think you search :

FlightDriver.StartAndFocusVessel (savegame, idx);

and to find idx you can use :

HighLogic.CurrentGame.flightState.protoVessels.IndexOf (YourProtoVessel);
or
FlightGlobals.Vessels.IndexOf (YourVessel);

But I think that you can't access FlightGlobals.Vessels from anywhere ;)

Link to comment
Share on other sites

Hello,

I think you search :

FlightDriver.StartAndFocusVessel (savegame, idx);

and to find idx you can use :

HighLogic.CurrentGame.flightState.protoVessels.IndexOf (YourProtoVessel);
or
FlightGlobals.Vessels.IndexOf (YourVessel);

But I think that you can't access FlightGlobals.Vessels from anywhere ;)

Thanks, I have access to FlightGlobals and the IDX for the intended vessel; however I'm unsure about the 'savegame' section of StartAndFocusVessel(savegame, idx). What should I use, is there a default?

Link to comment
Share on other sites

I've used this:

string _saveGame = GamePersistence.SaveGame ("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
FlightDriver.StartAndFocusVessel (_saveGame, _idx);

Perhaps "HighLogic.CurrentGame.Updated ()" would also work, I haven't try ...

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