Jump to content

EVA: identify the ship you left - is KSPAddon different?


Recommended Posts

For some reason (i.E. the star trek tricorder my kerbals get, I need to know for certain, wich vessel the kerbal came from.

My Kerbals leave the vessel on two ways, "normal" EVA and they get beamed out by the transporter..

In both situations, I need to identify the "MotherShip".

It seems onVesselChange does not get fired in all instances.

Did I miss any obviouse detail or function?

I've tested on Vessel change in two classes, a KSPaddon (see below) and the tricorder PartModule.

It wasn't fired in both.. ??

Additionally, my ineptitude let's me run in an other wall aswell by testing some workarounds..

maybe someone can help me there:

I got an allways-running background singleton setup with:

    [KSPAddon(KSPAddon.Startup.Flight, true)]
public sealed class LCARS_Util_FlightControll : MonoBehaviour
{
private static LCARS_Util_FlightControll _instance;
public static LCARS_Util_FlightControll Instance
{
get
{
if (_instance == null)
{
_instance = new LCARS_Util_FlightControll();
}

return _instance;
}
}
// [snip]
public Vessel lastVessel;
public Vessel getlastVessel()
{
UnityEngine.Debug.Log("LCARS_Util_FlightControll: lastVessel : this.lastVessel.name=" + this.lastVessel.name);
return this.lastVessel;
}
// [snip]

now when the tricorder runs:

                    MotherShip = LCARS_Util_FlightControll.Instance.getlastVessel();

Mothership should hold lastVessel but the function throws an exception (NRE) - is KSPAddon not like other classes? I've done that singleton thing for other classes as well, there the same works, but none is a KSPAddon.

FYI: lastVessel is assigned correctly in the KSPAddon class according to the logs.. - but the tricorder get's a NULL value delivered..

I am either inept or I'm missing something obvious here or both - either way, I'm puzzled..

Thank's for any hints..

Link to comment
Share on other sites

  • 2 weeks later...

This isn't a full answer because I'm away from my dev computer right now but...

Have you tried listening to the OnCrewEva(...) event? It passes in a from and to part. You can use that to do something like fromPart.vessel.flightID and toPart.vessel.flightID (or missionID or however else you track the vessels).

I need to solve this problem as well soon. I'll post an update here if I find a better method.

Link to comment
Share on other sites

This isn't a full answer because I'm away from my dev computer right now but...

Have you tried listening to the OnCrewEva(...) event? It passes in a from and to part. You can use that to do something like fromPart.vessel.flightID and toPart.vessel.flightID (or missionID or however else you track the vessels).

I need to solve this problem as well soon. I'll post an update here if I find a better method.

thank's, will try that.. :-)

I'm not sure it will help though, because my kerbals only partially go "on EVA" - mainly I need it for when I "beam" kerbals out, the star trek way.

My intermittent solution, is for now, to display a ship list in my "Tricorder"-addon where the user can select.

but an automatic solution would be preferable.

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