Jump to content

Crew information


Recommended Posts

I am trying to get some info on the crew when my custom commandpod explodes and write it to a file.

Here is my code:

  protected override void onPartExplode()
{
print('KIA!');

try
{
// file is comma delimited
// name,data\n
if (!File.Exists(hofFile)) File.Create(hofFile);

string fileContents = File.ReadAllText(hofFile);

// get list of crew KIA
foreach (ProtoCrewMember pcm in KerbalCrewRoster.CrewRoster)
{
string crewman = pcm.KerbalRef.crewMemberName;

print(crewman);
print(pcm.name);
print(pcm.courage.ToString());
fileContents += string.Format('{0},KIA,{1},{2},{3}\n', crewman, FlightGlobals.ActiveVessel.vesselName, DateTime.Now.ToString('MM-dd-yyyy'), FlightGlobals.ActiveVessel.missionTime);
}

File.WriteAllText(hofFile, fileContents);

print('Crew HoF saved');
}
catch (Exception)
{
// ignore
}

base.onPartExplode();
}

It doesn\'t appear to be going through the crew list at all. I also tried FlightGlobals.ActiveVessel.GetVesselCrew to no avail.

Can anyone help?

I must say that this plugin development has left me clueless on numerous occasions. Stuff you think should work just doesn\'t (like playing an mp3 I added to the sounds folder).

Link to comment
Share on other sites

It seems the crew is already completely deleted by the time onPartExplode() is called.

So I create a copy of the crew in onFlightStarted instead. Now I can use them even after they\'re gone.

BTW, I might throw a random name generator in there for the little kerbs, or even make a crew customization plugin.

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