Jump to content

Link Hogthrob

Members
  • Posts

    43
  • Joined

  • Last visited

Posts posted by Link Hogthrob

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

  2. Majiir,

    Something like this might work. (I have not tested any of this, but its a standard Observer pattern scenario)

    UPDATE: Upon review this isn\'t quite right. I need time to think about it outside of work hours. Its close. Sorta.

    public interface IKSPPartCallback

    {

    void PartActivated(Part partThatWasActivated);

    void PartDestroyed(Part partThatWasDestroyed);

    }

    public class KSPPart : Part

    {

    static List<IKSPPartCallback> _callbacklist = new List<IKSPPartCallback>();

    protected void Subscribe(IKSPPartCallback subscriber) { // add to list };

    protected void Unsubscribe(IKSPPartCallback subscriber) { // remove from list };

    protected override onPartActivate()

    {

    foreach (IKSPPartCallback part in _callbacklist)

    part.PartActivated();

    }

    protected override onPartDestroyed()

    {

    foreach (IKSPPartCallback part in _callbacklist)

    part.PartDestroyed();

    }

    }

    public class MyPart : KSPPart, IKSPPartCallback

    {

    public void PartActivated(Part partThatWasActivated)

    {

    // check if its the part you are watching

    }

    public void PartDestroyed(Part partThatWasDestroyed)

    {

    // check if its the part you are watching

    }

    }

  3. This may not be the proper forum, but it is a request and it does deal with plugins, so here goes...

    Visual Studio displays any XML comments you place before your classes, methods, etc. in object browser and intellisense.

    Makes it much easier for plugin developers to see what your objects and functions are for.

    Example:

    /// <summary>

    /// This method makes your ship explode.

    /// <summary>

    public void Boom()...

    Would display as:

    Your function specifics etc.

    Summary:

    This method makes your ship explode.

    It takes a little more time to document your code, but would be beneficial to the rest of us.

    Thank you!

  4. PiSA-D1 Countdown Decoupler (version 1.0)

    Pigs in Space Auronautics Inc., Link Hogthrob CEO and Captain of the Swinetrek

    License: Just take the code, it ain\'t that great. (PiS-PL?)

    In the vast reaches of space no one can here you scream (except Piggy and Dr. Strangepork). Scream out of boredom, not that I frighten easily...

    Between our stopover at the Vegan mud planet and Sally\'s Slop Shack on Delta Orionis, I threw together this complex contraption I call the Countdown Decoupler.

    Space Center starts the timer and in 10 seconds your rocket engines fire no matter how much your crew cries and screams with anxiety.

    Here are some screen shots for your enjoyment:

    Countdown Decoupler in the VAB

    PiSAD1inVAB.jpg

    Start of your flight

    PiSAD1_FlightStart.jpg

    Abort button (Space Center control only)

    PiSAD1_Abort.jpg

    PiSAD1_PostLaunch.jpg

    The timer continues until you close it or it will close automatically after 30 seconds of flight time.

    Source code and downloads:

    http://dl.dropbox.com/u/2922725/CountdownDecoupler.zip

  5. I see some crew management objects and functions and was wondering if anyone has been able to monitor a crewman\'s emotional state?

    Also, does anyone know how to play an mp3 or wav audio clip in unity?

    I had the idea of making a comm system where you can hear their squeals, giggles, or screams depending on the crew\'s mental health and maybe add some for other events in the flight as well.

  6. Just stumbled upon this thread...

    I\'ve been writing code for a long time. BASIC and Logo as a kid and in high school. Pascal, FORTRAN, COBOL, Scheme, and C++ in college.

    Professionally, I did some Perl and Javascript in the mid 90s for websites. Then Powerbuilder in the late 90s. Started with C++ again for commercial windows apps in \'99. Have done some VB and VBScript. Started dabbling in C# in 2002 or 2003, then went full tilt .Net/C# at work in 2007.

    I have some DirectX experience and Managed DX, and just a tiny bit of mucking around in XNA.

    I am a Senior Software Engineer by title, but more of a Software Engineering Manager, since I am doing more management than code nowadays.

  7. If you wanted to get fancy, you could create a local repository of installed parts and old backup parts. Use a zip file and an xml. Then they could change back and forth whenever they wanted. I'm not familiar with the ionic zip dll but it probably has a way to get the list of files in the zip. The XML would act as a database to tell your app what is installed and backed up and how to match things with what folder/files in the zip.

    <installed>

    <part_name1/>

    <metadata_for_part/>

    <location>path</location>

    <replacement_for>backedup_part_name</replacement_for>

    </installed>

    <backup>

    <part_name1/>

    <metadata_for_part/>

    <zipfolder_name>path</zipfolder_name>

    <replaced_by>part_name</replaced_by>

    </backup>

  8. Any of you extremely talented individuals up to a request?

    I need a head shot for Capt'n Skunk E. Monkey the Pirate for use as an avatar and possibly a sig image.

    The head needs to be that of a monkey. The colors should be that of a skunk, i.e. black with white stripe.

    He needs an eye patch and an earring, possibly a pirate hat/space helmet combination.

    I would forever be in your debt and willing to tweak a part texture or two for you in trade.

    Arrr!

    Capt'n Skunk E. Monkey

    How about this?

    skunkmonkey.png

    May not be what you want but it is amusing.

  9. beakerkerman.png

    Here we have one of the many fine employees of KSP Mission Control Center.

    Dr. Beaker Kerman is the lead scientist on KSP's latest liquid rocket engine, the AWH (A.ccident W.aiting to H.appen) Mark XVII. The AWH's sixteen previous launch attempts have ended prematurely in fiery explosions, but we believe the Mark 17 will be THE engine that gets Kermen well past the launch platform.

    Doesn't Beaker just exude confidence and poise? Good luck sir! The people of Kearth are proud of your pioneering spirit.

  10. Greetings and felicitations fellow Kerbalnauts!

    This is such a nifty little program and I can't wait to get some of these future additions.

    Wish the keyboard wasn't so sensitive sometimes though...

    Anyway, Jeb and I will see you in orbit! 8)

×
×
  • Create New...