Jump to content

KSPEvent right-click on cmd pod doesn't work when no crew


Recommended Posts

This is in a PartModule which is added to all command pods using ModuleManager

I have the following code:

[KSPEvent (/*active = true,*/ guiActive = true, guiActiveEditor = true, guiActiveUnfocused = true, guiName = "Persistent pod name")]
public void ActivateEvent ()
{
	GameObject gObj = new GameObject ("PDPNwindow", typeof(PDPN_EntryWindow));
	DontDestroyOnLoad (gObj);
	pdpnEntryWindow = (PDPN_EntryWindow)gObj.GetComponent (typeof(PDPN_EntryWindow));

	pdpnEntryWindow.Invoke (this, storedVesselName, Utils.getModulePartParent (this).vesselType, priority);
}

What's happening is that in the editor, it works on all the command pods.  When in flight, it only works if there is at least one crew in the command pod.  I also tried this with the "active = true" uncommented.

I also tried adding "guiActiveUncommand = true", but that didn't help either.

Any suggestions?

Thanks in advance

Link to comment
Share on other sites

If guiActive and active and guiActiveUncommand are all true it should be available and work in flight regardless of whether the command pod/vessel is controllable or not.
If guiActive and active are true and guiActiveUncommand is false then the vessel must be controllable.
In the Editor you just need guiActiveEditor and active to be true.
So did you try with all three set to active? If you did then I'm not sure why it's not working. It should.

Link to comment
Share on other sites

Just tried this:

    [KSPEvent (active = true,guiActive = true, guiActiveEditor = true, guiActiveUnfocused = true,  guiActiveUncommand = true, guiName = "Persistent pod name")]
        public void ActivateEvent ()

	[KSPEvent (active = true,guiActive = true, guiActiveEditor = true, guiActiveUnfocused = true,  guiActiveUncommand = true, guiName = "Persistent pod name")]
		public void ActivateEvent ()

still didn't work. So it must be something in my code.  The vessel is being renamed at staging, I wonder if that's causing an issue

Forgot to mention that this all started (it used to work) when I switched from Xamarin to MS Visual Studio.  Shouldn't make a difference, but who knows

Link to comment
Share on other sites

Oh, I just found the problem.  For some reason, after the staging event, the following two parameters are set to false:

guiActiveUncommand = False
guiActiveUnfocused = False

I saw this in the persistent file.  So now I need to figure out why, and how to reset them back to true.

Link to comment
Share on other sites

4 minutes ago, linuxgurugamer said:

Oh, I just found the problem.  For some reason, after the staging event, the following two parameters are set to false:


guiActiveUncommand = False
guiActiveUnfocused = False

I saw this in the persistent file.  So now I need to figure out why, and how to reset them back to true.

Hmmm.. If that's true just register for the event GameEvents.onStageActivate and then set them in that method.
 

Spoiler

eg (typing this on my phone, so untested, could have some errors):

In OnStart of your partmodule:
GameEvents.onStageActivate.Add(onStageActivate);

private void onStageActivate()
{
     Events["ActivateEvent"].guiActiveUncommand = true;
     Events["ActivateEvent"].guiActiveUnfocused = true;
}

Dont forget remove the GameEvent registration in your partmodule OnDestroy.
GameEvents.onStageActivate.Remove(onStageActivate);

 

Link to comment
Share on other sites

18 minutes ago, JPLRepo said:

Hmmm.. If that's true just register for the event GameEvents.onStageActivate and then set them in that method.
 

  Reveal hidden contents

eg (typing this on my phone, so untested, could have some errors):

In OnStart of your partmodule:
GameEvents.onStageActivate.Add(onStageActivate);

private void onStageActivate()
{
     Events["ActivateEvent"].guiActiveUncommand = true;
     Events["ActivateEvent"].guiActiveUnfocused = true;
}

Dont forget remove the GameEvent registration in your partmodule OnDestroy.
GameEvents.onStageActivate.Remove(onStageActivate);

 

Well, that's what I'm trying to do, but getting errors

edit.  It helps to put it in the right spot.  Thanks for the help, I got it working

Edited by linuxgurugamer
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...