Jump to content

Adding to the right-click menu on other craft


Superfluous J

Recommended Posts

When you right-click a docking port on another ship, you can set it as the target. If you right click anything, you can center the camera on it now. How would I in code add to that menu?

If you're curious, I'm thinking something akin to Extraplanetary Launchpad's recycle bin, only it works just from right clicking the other craft and saying "recycle"

Link to comment
Share on other sites

4 hours ago, Diazo said:

Isn't that just a KSPEvent with guiActiveUnfocused = true?

Not sure about the center camera option, but the docking port one is almost certainly that.

D.

Possibly. I don't see in the configs where it's set on those parts but I am by no means an expert (hence the question :)). I'll play around with that tonight thanks!

Link to comment
Share on other sites

AHA. The below code DOES work, only it only works with an EVA'd Kerbal. I need this to work while controlling another active ship.

The below code is valid but I removed most of the commentary because I wrote it before I realized what the actual problem was. The code works but only with an EVA'd Kerbal.

On 12/21/2016 at 10:02 AM, Diazo said:

Isn't that just a KSPEvent with guiActiveUnfocused = true?

Not sure about the center camera option, but the docking port one is almost certainly that.

D.

 

source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RightClickRecycler
{
    public class RCRecycle : PartModule
    {
        [KSPEvent(guiActive = false, guiActiveEditor = false, guiActiveUnfocused = true, guiName = "Recycle")]
        public void DoRCRecycle()
        {
            print("RCR: It worked!");
        }
    }
}

modulemanager config:

@PART[*]:FINAL
{
	MODULE
	{
		name = RCRecycle
	}
}

 

Edited by 5thHorseman
Link to comment
Share on other sites

What happens if you set externalToEVAOnly = false in the KSPEvent?

Those two settings (guiActiveUnfocued and externalToEVAOnly) would be what I expect to control visibility of the event as you are trying to use it.

D.

Link to comment
Share on other sites

3 hours ago, Diazo said:

What happens if you set externalToEVAOnly = false in the KSPEvent?

Those two settings (guiActiveUnfocued and externalToEVAOnly) would be what I expect to control visibility of the event as you are trying to use it.

D.

That is extremely close. It does add it to command pods, but it's still on the Krebal. That's surely "close enough" to what I want as I'm going to at least warn when you don't have storage for the ship you're recycling (a Kerbal would never have enough storage, I'd think) an may even disallow if you can't store everything. Or maybe I'll allow a temporary quasi-storage that you can load into nearby ships or something...

Thanks everybody!

Link to comment
Share on other sites

To not add it to the Kerbal you need to modify the MM patch you are using.

I can't remember if it was in KSP 1.0 or 1.1, but they added "kerbal" and "flag" objects so MM scripts could affect those.

You'll have to dig up the specifics yourself as I don't know them myself, but I know the functionality is there.

D.

Link to comment
Share on other sites

35 minutes ago, Diazo said:

To not add it to the Kerbal you need to modify the MM patch you are using.

I can't remember if it was in KSP 1.0 or 1.1, but they added "kerbal" and "flag" objects so MM scripts could affect those.

You'll have to dig up the specifics yourself as I don't know them myself, but I know the functionality is there.

D.

But that would remove the "recycle" menu option from right-clicked Kerbals. Which is probably a good thing but not what the problem is. The problem isn't that the Kerbal has the menu option, it's that a ship has the menu option when I'm controlling a Kerbal.

Link to comment
Share on other sites

Oh, you're going to have to change the KSPEvent's visibility in code then.

Something like this in the partModule:

if(FlightGlobals.ActiveVessel.isEva)
{
	KSPEvent.hide(); //pseduo-command, not actually valid
}
else
{
	KSPEvent.show(); //more pseudo-code
}

So if a kerbal is being controlled, the KSPEvent is hidden, otherwise it shows. Can add checks for room to recycle and such here too.

D.

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